Categories
Golang

use go module

Enable go module in vscode.

{
    "editor.fontSize": 18,
    "extensions.ignoreRecommendations": false,
    "java.errors.incompleteClasspath.severity": "ignore",
    "editor.fontLigatures": true,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "alt",
    "editor.formatOnPaste": true,
    "rust.mode": "legacy",
    "workbench.colorTheme": "Sublime MavensMate Monokai",
    "workbench.iconTheme": "eq-material-theme-icons",
    "materialTheme.fixIconsRunning": false,
    "[python]": {
        
    },
    "workbench.fontAliasing": "auto",
    "go.formatTool": "goimports",
    "go.useLanguageServer": true,
    "go.toolsManagement.autoUpdate": true,
    "go.toolsEnvVars": {
        "GO111MODULE": "on"
    }
}

Init the root module

$ go mod init github.com/xxx/go-module

module github.com/xxx/go-module

go 1.16

Get the dependency package

go get rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: downloading rsc.io/sampler v1.3.0
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
go get: added rsc.io/quote v1.5.2

list all dependency

go list -m all
github.com/xxx/go-module
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
rsc.io/quote v1.5.2
rsc.io/sampler v1.3.0

Upgrade one dependency

@MacBook-Pro ~/D/C/g/go-module> go get golang.org/x/text
go get: upgraded golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c => v0.3.6

go get rsc.io/[email protected]
go: downloading rsc.io/sampler v1.3.1
go get: upgraded rsc.io/sampler v1.2.1 => v1.3.1

Remove unused dependency

@MacBook-Pro ~/D/C/g/go-module> go mod tidy

Leave a Reply

Your email address will not be published. Required fields are marked *