下载

安装相关工具

框架Cli

代码Lint

  • golangci-lint go install github.com/golangci/golangci-lint/cmd/[email protected]

  • gofumpt go install mvdan.cc/[email protected] goland设置

    GoLand doesn’t use gopls so it should be configured to use gofumpt directly. Once gofumpt is installed, follow the steps below:

    • Open Settings (File > Settings)
    • Open the Tools section
    • Find the File Watchers sub-section
    • Click on the + on the right side to add a new file watcher
    • Choose Custom Template

    When a window asks for settings, you can enter the following:

    • File Types: Select all .go files
    • Scope: Project Files
    • Program: Select your gofumpt executable
    • Arguments: -w $FilePath$
    • Output path to refresh: $FilePath$
    • Working directory: $ProjectFileDir$
    • Environment variables: GOROOT=$GOROOT$;GOPATH=$GOPATH$;PATH=$GoBinDirs$

    To avoid unnecessary runs, you should disable all checkboxes in the Advanced section.

buf

需要使用格式化功能,windows环境需要安装diff工具,goland则需要安装插件Buf for Protocol Buffers

buf 首页: https://github.com/bufbuild/buf

其他