跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 快疯了,使用 vscode 开发 go,环境变量问题,这个问题一直困扰好久

发表于

使用 go1.21 开发,之前电脑有 1.19 版本

1.21 版本安装到了/Users/zhuxiaoyu/Desktop/go121 目录中

/etc/profile

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
fi
export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOPATH=/Users/zhuxiaoyu/Desktop/gopath

~/.bash_profile

export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOPATH=/Users/zhuxiaoyu/Desktop/gopath
export GOBIN=$GOPATH/bin
export PROTOBUF_HOME=/usr/local/protobuf
export GO111MODULE=auto
PATH=$PATH:$GOBIN:$PROTOBUF_HOME/bin

~/.zshrc

export GOPATH=/Users/zhuxiaoyu/Desktop/gopath
export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOBIN=$GOPATH/bin
export PROTOBUF_HOME=/usr/local/protobuf
export GO111MODULE=on
export GETHBIN=/Users/zhuxiaoyu/Desktop/geth/build/bin

go env

GO111MODULE='auto'
GOARCH='amd64'
GOBIN='/Users/zhuxiaoyu/Desktop/gopath/bin'
GOCACHE='/Users/zhuxiaoyu/Library/Caches/go-build'
GOENV='/Users/zhuxiaoyu/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/zhuxiaoyu/Desktop/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/zhuxiaoyu/Desktop/gopath'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/zhuxiaoyu/Desktop/go121'
GOSUMDB=''
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/Users/zhuxiaoyu/Desktop/go121/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ys/nth2j_v53q55rqfkhvdfnj_80000gn/T/go-build2234700829=/tmp/go-build -gno-record-gcc-switches -fno-common

vscode 的配置

"go.alternateTools": {
        "go.goroot":"/Users/zhuxiaoyu/Desktop/go121",
        "go.gopath":"/Users/zhuxiaoyu/Desktop/gopath"
    }

vscode 报错提示

go: cannot find GOROOT directory: /Users/zhuxiaoyu/Desktop/gopath/go1.19.9

都快疯了,到底这个 vscode 读的哪里的环境变量

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.