中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

go語言有哪些環(huán)境變量-創(chuàng)新互聯(lián)

go語言有哪些環(huán)境變量?針對這個問題,今天小編總結這篇有關golang環(huán)境變量的文章,可供感興趣的小伙伴們參考借鑒,希望對大家有所幫助。

創(chuàng)新互聯(lián)建站于2013年創(chuàng)立,是專業(yè)互聯(lián)網技術服務公司,擁有項目成都網站制作、做網站、外貿營銷網站建設網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元樂都做網站,已為上家服務,為樂都各地企業(yè)和個人服務,聯(lián)系電話:028-86922220

環(huán)境變量代表的含義:

$ go help environment
The go command and the tools it invokes consult environment variables
for configuration. If an environment variable is unset, the go command
uses a sensible default setting. To see the effective setting of the
variable <NAME>, run 'go env <NAME>'. To change the default setting,
run 'go env -w <NAME>=<VALUE>'. Defaults changed using 'go env -w'
are recorded in a Go environment configuration file stored in the
per-user configuration directory, as reported by os.UserConfigDir.
The location of the configuration file can be changed by setting
the environment variable GOENV, and 'go env GOENV' prints the
effective location, but 'go env -w' cannot change the default location.
See 'go help env' for details.

General-purpose environment variables:

     GCCGO
         The gccgo command to run for 'go build -compiler=gccgo'.
     GOARCH
         The architecture, or processor, for which to compile code.
         Examples are amd64, 386, arm, ppc64.
     GOBIN
         The directory where 'go install' will install a command.
     GOCACHE
         The directory where the go command will store cached
         information for reuse in future builds.
     GODEBUG
         Enable various debugging facilities. See 'go doc runtime'
         for details.
     GOENV
         The location of the Go environment configuration file.
         Cannot be set using 'go env -w'.
     GOFLAGS
         A space-separated list of -flag=value settings to apply
         to go commands by default, when the given flag is known by
         the current command. Each entry must be a standalone flag.
         Because the entries are space-separated, flag values must
         not contain spaces. Flags listed on the command line
         are applied after this list and therefore override it.
     GOOS
         The operating system for which to compile code.
         Examples are linux, darwin, windows, netbsd.
     GOPATH
         For more details see: 'go help gopath'.
     GOPROXY
         URL of Go module proxy. See 'go help modules'.
     GOPRIVATE, GONOPROXY, GONOSUMDB
         Comma-separated list of glob patterns (in the syntax of Go's path.Match)
         of module path prefixes that should always be fetched directly
         or that should not be compared against the checksum database.
         See 'go help module-private'.
     GOROOT
         The root of the go tree.
     GOSUMDB
         The name of checksum database to use and optionally its public key and
         URL. See 'go help module-auth'.
     GOTMPDIR
         The directory where the go command will write
         temporary source files, packages, and binaries.

Environment variables for use with cgo:

     AR
         The command to use to manipulate library archives when
         building with the gccgo compiler.
         The default is 'ar'.
     CC
         The command to use to compile C code.
     CGO_ENABLED
         Whether the cgo command is supported. Either 0 or 1.
     CGO_CFLAGS
         Flags that cgo will pass to the compiler when compiling
         C code.
     CGO_CFLAGS_ALLOW
         A regular expression specifying additional flags to allow
         to appear in #cgo CFLAGS source code directives.
         Does not apply to the CGO_CFLAGS environment variable.
     CGO_CFLAGS_DISALLOW
         A regular expression specifying flags that must be disallowed
         from appearing in #cgo CFLAGS source code directives.
         Does not apply to the CGO_CFLAGS environment variable.
     CGO_CPPFLAGS, CGO_CPPFLAGS_ALLOW, CGO_CPPFLAGS_DISALLOW
         Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW,
         but for the C preprocessor.
     CGO_CXXFLAGS, CGO_CXXFLAGS_ALLOW, CGO_CXXFLAGS_DISALLOW
         Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW,
         but for the C++ compiler.
     CGO_FFLAGS, CGO_FFLAGS_ALLOW, CGO_FFLAGS_DISALLOW
         Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW,
         but for the Fortran compiler.
     CGO_LDFLAGS, CGO_LDFLAGS_ALLOW, CGO_LDFLAGS_DISALLOW
         Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW,
         but for the linker.
     CXX
         The command to use to compile C++ code.
     FC
         The command to use to compile Fortran code.
     PKG_CONFIG
         Path to pkg-config tool.

Architecture-specific environment variables:

     GOARM
         For GOARCH=arm, the ARM architecture for which to compile.
         Valid values are 5, 6, 7.
     GO386
         For GOARCH=386, the floating point instruction set.
         Valid values are 387, sse2.
     GOMIPS
         For GOARCH=mips{,le}, whether to use floating point instructions.
         Valid values are hardfloat (default), softfloat.
     GOMIPS64
         For GOARCH=mips64{,le}, whether to use floating point instructions.
         Valid values are hardfloat (default), softfloat.
     GOWASM
         For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use.
         Valid values are satconv, signext.

Special-purpose environment variables:

     GCCGOTOOLDIR
         If set, where to find gccgo tools, such as cgo.
         The default is based on how gccgo was configured.
     GOROOT_FINAL
         The root of the installed Go tree, when it is
         installed in a location other than where it is built.
         File names in stack traces are rewritten from GOROOT to
         GOROOT_FINAL.
     GO_EXTLINK_ENABLED
         Whether the linker should use external linking mode
         when using -linkmode=auto with code that uses cgo.
         Set to 0 to disable external linking mode, 1 to enable it.
     GIT_ALLOW_PROTOCOL
         Defined by Git. A colon-separated list of schemes that are allowed
         to be used with git fetch/clone. If set, any scheme not explicitly
         mentioned will be considered insecure by 'go get'.
         Because the variable is defined by Git, the default value cannot
         be set using 'go env -w'.

Additional information available from 'go env' but not read from the environment:

     GOEXE
         The executable file name suffix (".exe" on Windows, "" on other systems).
     GOGCCFLAGS
         A space-separated list of arguments supplied to the CC command.
     GOHOSTARCH
         The architecture (GOARCH) of the Go toolchain binaries.
     GOHOSTOS
         The operating system (GOOS) of the Go toolchain binaries.
     GOMOD
         The absolute path to the go.mod of the main module,
         or the empty string if not using modules.
     GOTOOLDIR
         The directory where the go tools (compile, cover, doc, etc...) are installed.

你可以使用以下命令查看你的go環(huán)境變量:

$ go env

接下來就來了解一下其他的環(huán)境變量。

GOARCH 和 GOOS

GOARCH :cpu架構,386、amd64、arm等,在交叉編譯的時候設置,可以編譯不同平臺的包。
GOOS:平臺,linux、windows等,通常和GOARCH搭配使用。
這里貼一下在不同平臺下交叉編譯的命令:

Mac下編譯Linux, Windows平臺的64位可執(zhí)行程序:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build test.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build test.go

Linux下編譯Mac, Windows平臺的64位可執(zhí)行程序:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build test.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build test.go

Windows下編譯Mac, Linux平臺的64位可執(zhí)行程序:
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build test.go
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build test.go

GOCACHE

這是go build產生的緩存,這可以加快編譯速度,我在GOCACHE打印出來的路徑下看到了一個README文件,它解釋了GOCACHE。

This directory holds cached build artifacts from the Go build system.
Run "go clean -cache" if the directory is getting too large.
See golang.org to learn more about Go.

可以使用"go clean -cache"命令清除編譯緩存。

GOENV

本地的go環(huán)境文件存儲位置,不可以用"go env -w"設置它。

以上就是golang環(huán)境變量的知識匯總,內容較為全面,小編相信有部分知識點可能是我們日常工作可能會見到或用到的。希望你能通過這篇文章學到更多知識。

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章名稱:go語言有哪些環(huán)境變量-創(chuàng)新互聯(lián)
URL地址:http://www.rwnh.cn/article38/hdhsp.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供全網營銷推廣、ChatGPT、網站設計、網站制作、品牌網站設計、電子商務

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
卢氏县| 巫溪县| 遂宁市| 田阳县| 罗平县| 饶河县| 麟游县| 栖霞市| 宁德市| 休宁县| 乐安县| 平阴县| 二连浩特市| 石门县| 江阴市| 平阴县| 卢龙县| 德兴市| 桂阳县| 阿合奇县| 崇仁县| 绵竹市| 开原市| 铅山县| 绥棱县| 玉山县| 防城港市| 六枝特区| 永康市| 阿拉善右旗| 霍山县| 边坝县| 金沙县| 枣阳市| 长宁区| 夏河县| 岐山县| 莲花县| 南丰县| 内丘县| 从江县|