VSCode = Visual Studio Code 에서 사용할 수 있는 확장(Extension) 입니다.
Go 에 대해 풍부한 언어 지원을 위한 확장입니다.
링크 : https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
Go 가 설치되어 있어야 합니다.
현재 설치된 Go path 는 Go: Current GOPATH 명령어로 확인 가능합니다.
IntelliSense
- Auto Completion of symbols as you type (using
gocode
) - Signature Help for functions as you type (using
gogetdoc
orgodef
+godoc
) - Quick Info on the symbol as you hover over it (using
gogetdoc
orgodef
+godoc
)
Code Navigation
- Go to or Peek Definition of symbols (using
gogetdoc
orgodef
+godoc
) - Find References of symbols and Implementations of interfaces (using
guru
) - Go to symbol in file or see the file outline (using
go-outline
) - Go to symbol in workspace (using
go-symbols
) - Toggle between a Go program and the corresponding test file.
Code Editing
- Code Snippets for quick coding
- Format code on file save as well as format manually (using
goreturns
orgoimports
orgofmt
) - Symbol Rename (using
gorename
. Note: For Undo after rename to work in Windows you need to havediff
tool in your path) - Add Imports to current file (using
gopkgs
) - Add/Remove Tags on struct fields (using
gomodifytags
) - Generate method stubs for interfaces (using
impl
) - Fill struct literals with default values (using
fillstruct
)
Diagnostics
- Build-on-save to compile code and show build errors. (using
go build
andgo test
) - Vet-on-save to run
go vet
and show errors as warnings - Lint-on-save to show linting errors as warnings (using
golint
,gometalinter
,megacheck
,golangci-lint
orrevive
) - Semantic/Syntactic error reporting as you type (using
gotype-live
)
Testing
- Run Tests under the cursor, in current file, in current package, in the whole workspace using either commands or codelens
- Run Benchmarks under the cursor using either commands or codelens
- Show code coverage either on demand or after running tests in the package.
- Generate unit tests skeleton (using
gotests
)
Debugging
- Debug your code, binaries or tests (using
delve
)
Others
- Install/Update all dependent Go tools
- Upload to the Go Playground (using
goplay
)
Commands
In addition to integrated editing features, the extension also provides several commands in the Command Palette for working with Go files:
Go: Add Import
to add an import from the list of packages in your Go contextGo: Current GOPATH
to see your currently configured GOPATHGo: Test at cursor
to run a test at the current cursor position in the active documentGo: Test Package
to run all tests in the package containing the active documentGo: Test File
to run all tests in the current active documentGo: Test Previous
to run the previously run test commandGo: Test All Packages in Workspace
to run all tests in the current workspaceGo: Generate Unit Tests For Package
Generates unit tests for the current packageGo: Generate Unit Tests For File
Generates unit tests for the current fileGo: Generate Unit Tests For Function
Generates unit tests for the selected function in the current fileGo: Install Tools
Installs/updates all the Go tools that the extension depends onGo: Add Tags
Adds configured tags to selected struct fields.Go: Remove Tags
Removes configured tags from selected struct fields.Go: Generate Interface Stubs
Generates method stubs for given interfaceGo: Fill Struct
Fills struct literal with default valuesGo: Run on Go Playground
Upload the current selection or file to the Go Playground