Skip to content

Commit feef97c

Browse files
committed
Update singleapp/build_constraints_unix
1 parent e560479 commit feef97c

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
version: '3'
22

33
tasks:
4+
default:
5+
cmds:
6+
- task: run
47
run:
58
cmds:
69
- go run .

examples/singleapp/build_constraints_unix/main.go

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build windows
2+
3+
package main
4+
5+
import "fmt"
6+
7+
func main() {
8+
fmt.Println("run on windows")
9+
}

0 commit comments

Comments
 (0)