加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

vscode go windows 版本build linux

发布时间:2020-12-14 03:57:03 所属栏目:Windows 来源:网络整理
导读:1.1选中要build的main.go,然后执行Open in Terminal 1.2在Terminal中执行go env d:goprojectssrcday1exp6go env set GOARCH=amd64 set GOBIN= set GOCACHE=C:UsersAdministratorAppDataLocalgo-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=a
1.1选中要build的main.go,然后执行Open in Terminal

1.2在Terminal中执行go env

d:goprojectssrcday1exp6>go env

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:UsersAdministratorAppDataLocalgo-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:goprojects
set GOPROXY=
set GORACE=
set GOROOT=D:program Filesgo
set GOTMPDIR=
set GOTOOLDIR=D:program Filesgopkgtoolwindows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:UsersADMINI~1AppDataLocalTempgo-build131073830=/tmp/go-build -gno-record-gcc-switches

1.3执行修改goos

d:goprojectssrcday1exp6>set GOOS=linux

d:goprojectssrcday1exp6>go env

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:UsersAdministratorAppDataLocalgo-build
set GOEXE=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=linux
set GOPATH=D:goprojects
set GOPROXY=
set GORACE=
set GOROOT=D:program Filesgo
set GOTMPDIR=
set GOTOOLDIR=D:program Filesgopkgtoolwindows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:UsersADMINI~1AppDataLocalTempgo-build488831346=/tmp/go-build -gno-record-gcc-switches

d:goprojectssrcday1exp6>go build

d:goprojectssrcday1exp6>

1.4 goos 和gorch取值范围

注意里面两个重要的环境变量GOOS和GOARCH,其中GOOS指的是目标操作系统,它的可用值为:

darwin
freebsd
linux
windows
android
dragonfly
netbsd
openbsd
plan9
solaris

一共支持10中操作系统。

GOARCH指的是目标处理器的架构,目前支持的有:

arm
arm64
386
amd64
ppc64
ppc64le
mips64
mips64le
s390x

一共支持9中处理器的架构,GOOS和GOARCH组合起来,支持生成的可执行程序种类很多

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读