go語言

1.安裝完以後,會自動添加一個GOROOT環境變量,指向的就是go的安裝目錄,這樣就能在各個路徑執行go命令linux

2.安裝完以後須要本身添加GOPATH環境變量,指向本身的項目目錄,這樣就能執行這個位置的代碼,還有下載的包也會默認導入到這個目錄下。git

3.go get github.....從github上拉去包 如:go get -v github.com/spf13/cobra/cobragithub

4.設置環境變量 set GOPATH=E:/go_test查看當前環境變量:echo %GOPATH%golang

5.sublime 調試 go, 把編譯系統選項設置爲go, ctrl+shift+p 安裝golang,Preferences->按鍵綁定-用戶,加入{ "keys": ["f5"], "command": "build", "args": {"variant": "Run"} }(可參照按鍵綁定默認)而後就能夠f5調試了。web

 6.git bash模擬post請求,curl -d "a=1" "http://localhost:8080",不加-d是get請求windows

 7.go語言部署到不一樣服務器方式:bash

  64位系統:服務器

  linux
  GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o web;curl

  windows
  GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o web;post

  mac

  GOOS=darwin GOARCH=amd64 go build -ldflags "-w -s" -o web

chmod -R 777 /home/test/web
8.若是報權限不夠,那麼先對文件執行chmod -R 777:好比:


 

vscode 先裝一個vscode的go插件而後在gopath/bin內安裝一堆github的東西配置go:

{
"git.path": "E:\\installedsoftware\\Git\\cmd\\git.exe",
// "editor.parameterHints": false,
// "editor.quickSuggestions": false,
"fileheader.Author": "ZhangShuai",
"fileheader.LastModifiedBy": "Janson",
"fileheader.tpl": "/*\r\n * @Author: {author} \r\n * @Date: {createTime} \r\n * @Last Modified by: {lastModifiedBy} \r\n * @Last Modified time: {updateTime} \r\n */\r\n",
"workbench.colorCustomizations": {
"editor.selectionBackground": "#6622aa"
},
"editor.wordWrap": "on",
"editor.minimap.enabled": false,
"window.zoomLevel": 3,
"workbench.colorTheme": "Material Theme",
"git.ignoreMissingGitWarning": true,
"sync.gist": "5fcee84fc617c99f20462cd915729978",
"sync.host": "",
"sync.pathPrefix": "",
"sync.quietSync": false,
"sync.askGistName": false,
"sync.removeExtensions": true,
"sync.syncExtensions": true,
"sync.autoDownload": false,
"sync.autoUpload": false,
"sync.lastUpload": "2018-05-08T11:50:08.998Z",
"sync.lastDownload": "",
"sync.forceDownload": false,
"git.autofetch": true,
"emmet.triggerExpansionOnTab": true,
"go.gopath": "D:\\workspace\\learn\\gotest",
"go.goroot": "C:\\Go",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
}
相關文章
相關標籤/搜索