lab043

command
v0.0.0-...-f10d331 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 1 Imported by: 0

README

+build

做这个实验是因为lab042中用到的库,分别有三个系统自己的文件。做下这个实验确定下是什么来触发这个忽略。

实验结果

  1. hello_windows.gohello_linux.go这样的文件是可以不加build tag,在golang中也会被识别。 但是hello_bsd.go没有被识别
  2. 不管是什么文件名,我们可以主动在该文件的第一行加上build tag。这样我们也可以指定这个文件可以在哪个系统上被使用, // +build linux darwin dragonfly freebsd netbsd openbsd

运行结果

windows

Imgur

ubuntu

Imgur

参考资料

  1. https://golang.org/pkg/go/build/#hdr-Build_Constraints
  2. http://studygolang.com/articles/5035

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL