Golang OS 확인

Jmnote (토론 | 기여)님의 2023년 2월 27일 (월) 11:55 판 (새 문서: ==개요== ;Go OS 확인 <syntaxhighlight lang='console'> package main import ( "fmt" "runtime" ) func main() { os := runtime.GOOS switch os { case "windows": fmt.Println("W...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

Go OS 확인
package main

import (
	"fmt"
	"runtime"
)

func main() {
	os := runtime.GOOS
	switch os {
	case "windows":
		fmt.Println("Windows")
	case "darwin":
		fmt.Println("MacOS")
	case "linux":
		fmt.Println("Linux")
	default:
		fmt.Printf("%s.\n", os)
	}
}

2 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}