Setup VS Code for GoLang

  1. Install Visual Studio Code from website:
    https://code.visualstudio.com/download
  2. Go to view > Extensions > Search Go. You will find an extension from Go Team at Google. Click on install.

3. After installing File > New File > Select a language > Go.
4. It will detect some missing plugins, so click on install all. Output will be like

Installing 6 tools at /Users/<>/go/bin in module mode.
gotests
gomodifytags
impl
goplay
staticcheck
gopls

Installing github.com/cweill/gotests/gotests@latest (/Users/user/go/bin/gotests) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (/Users/user/go/bin/gomodifytags) SUCCEEDED
Installing github.com/josharian/impl@latest (/Users/user/go/bin/impl) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (/Users/user/go/bin/goplay) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (/Users/user/go/bin/staticcheck) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (/Users/user/go/bin/gopls) SUCCEEDED

All tools successfully installed. You are ready to Go. 🙂

Go CLI : It’s a command prompt interface to execute different commands provide with go package.

  • go run : Compile and execute go file – eg. go run hello.go
  • go build : To compile go source file bundle. – eg. go build hello.go
  • go install : Compiles and installs a package
  • go get : Download a go package source code
  • go tests : Run all the tests associated with current project
  • go version: Display current version of Go binary
Advertisement

Leave a Reply

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

3 + one =