golang
安装 VSCode
略
插件 Remote SSH
登录远程
ssh root@172.19.129.68 -A
免密登录
本机生成 ssh key
ssh-keygen
复制pub到远程
- type ~/.ssh/.rsa_pub
- 复制内容
- 远程
echo '粘贴内容' >> ~/.ssh/authorized_keys
- VSCode中 F1 -> Reload Window
安装 golang 及 环境
wget -O go.tar.gz https://studygolang.com/dl/golang/go1.17.6.linux-amd64.tar.gz
&& tar -C /usr/local -xzf go.tar.gz && ln -sf /usr/local/go/bin/go /usr/bin/go
yum install -y gcc gcc-c++
环境配置
echo 'export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
' >> ~/.bashrc
GOPROXY
VSCode 配置
- 安装插件
- Go
- Go outliner
- Ctrl+Shift+P 输入 ?GO: Install/Update Tools 安装全部
若 GOPROXY 无效, 则 reboot
- 编辑配置 .vscode/setting.json
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useLanguageServer": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
}
- 插件 prettier
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnPaste": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tabSize": 2,
"workbench.startupEditor": "none",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.linkedEditing": true,
"editor.formatOnSave": true,
"prettier.printWidth": 200,
"prettier.tabWidth": 2,
"prettier.useTabs": false,
"prettier.semi": false,
"prettier.singleQuote": true,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.proseWrap": "preserve",
"prettier.arrowParens": "avoid",
"prettier.bracketSpacing": true,
"prettier.endOfLine": "auto",
"prettier.htmlWhitespaceSensitivity": "ignore",
"prettier.ignorePath": ".prettierignore",
"prettier.jsxBracketSameLine": false,
"prettier.jsxSingleQuote": true,
"prettier.requireConfig": false,
"prettier.trailingComma": "all",
"[go]": {
"editor.defaultFormatter": "golang.go"
},
|