goland之基础使用

安装go之后,

 

1.设置环境变量

GOROOT,GOPATH

2.goland配置

 

 

配置GOPATH

 

 

GO Modules

  GOPROXY=https://goproxy.io,direct

 

 

设置自动代码格式化与代码检查:

点击 settings > Tools > File Watchers

 

 新增

go fmt
goimports

 

 

开发利器: Live template

 

 

 常用插件:

  1.Key Promoter X   快捷键提示插件

 

 

添加服务启动配置

        选择run  config  -> 编辑选择Go Build -> 

    Run kind: 选择File

              Files: 选择具体的执行的main.go   例如/app/demo/cmd/main.go

             Working directory:  指定目录地址  例如:/app/demo

            Program arguments: 执行后面的参数  例如: -c config.yaml

例如启动命令如下:

go run cmd/main.go -c config.yaml

 

 

ide中显示.git目录

默认加载一个git的仓库,ide中并不显示,需要进行设置

 Settings > Editor > File Types 从Ignore files and folders中删除.git即可

 

 

常见错误:

1.proxyconnect tcp: dial tcp 127.0.0.1:8888: connectex: No connection could be made because the target machine actively refused it. 

 

 

 goland 设置里Http Proxy 不知道为什么默认是Manual proxy configuration ,改为No proxy 后正常了

 

posted @ 2022-04-19 15:58  X-Wolf  阅读(875)  评论(0)    收藏  举报