File tree Expand file tree Collapse file tree 4 files changed +48
-17
lines changed
examples/singleapp/build_constraints_unix Expand file tree Collapse file tree 4 files changed +48
-17
lines changed Original file line number Diff line number Diff line change 11version : ' 3'
22
33tasks :
4+ default :
5+ cmds :
6+ - task : run
47 run :
58 cmds :
69 - go run .
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ //go:build unix
2+
3+ // Go 1.19 で Build Constraints に新たに unix が追加された。
4+ //
5+ // - https://go.dev/doc/go1.19#go-unix
6+ //
7+ // 実際のマッピングは $(go env GOROOT)/src/cmd/dist/build.go に以下のように定義されている。(Go 1.25)
8+ //
9+ // var unixOS = map[string]bool{
10+ // "aix": true,
11+ // "android": true,
12+ // "darwin": true,
13+ // "dragonfly": true,
14+ // "freebsd": true,
15+ // "hurd": true,
16+ // "illumos": true,
17+ // "ios": true,
18+ // "linux": true,
19+ // "netbsd": true,
20+ // "openbsd": true,
21+ // "solaris": true,
22+ // }
23+ //
24+ // なので、linux, macOS(darwin) の両方で有効にする場合は unix を指定すれば良い。
25+ //
26+ // # REFERENCES
27+ // - https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/cmd/dist/build.go;l=1070
28+ // - https://dev.to/emreodabas/quick-guide-go-119-features-1j40
29+ // - https://go.dev/doc/go1.19#go-unix
30+ package main
31+
32+ import "fmt"
33+
34+ func main () {
35+ fmt .Println ("run on unix" )
36+ }
Original file line number Diff line number Diff line change 1+ //go:build windows
2+
3+ package main
4+
5+ import "fmt"
6+
7+ func main () {
8+ fmt .Println ("run on windows" )
9+ }
You can’t perform that action at this time.
0 commit comments