This VSCode extension provides a comprehensive collection of useful Golang snippets to accelerate your Go development workflow.
Most of the snippets are based on examples from gobyexample.com.
- Consistent prefix pattern (
go:) for easy discovery - Covers essential Go patterns and constructs
- Properly formatted with placeholders for customization
- Organized by category (basics, functions, data structures, concurrency, HTTP)
| Prefix | Description |
|---|---|
go: hello |
Go Hello World app |
go: pkg |
Set a Go package name |
go: fn |
A simple function |
go: func |
A simple function |
go: func-public |
A simple public function |
go: print |
Print to console |
go: main |
Main Function |
go: var |
Variable |
go: short-var |
Short variable |
go: const |
Constant |
go: switch |
Switch |
go: arr |
Array |
go: slice |
Slice |
go: map |
Map |
go: range |
Range |
go: func-mult |
Function with multiple values returned |
go: func-variadic |
Variadic functions |
go: pointer |
Pointer |
go: struct |
Struct |
go: struct-embedded |
Embedded struct |
go: struct-method |
Method for a struct |
go: error |
Raise error |
go: routine-anon |
Anonymous goroutine |
go: routine-basic |
Basic goroutine |
go: channel |
Channel |
go: channel-buffered |
Buffered channel |
go: channel-wait-select |
Using select to wait on channels |
go: channels-range |
Range over channels |
go: worker-pools |
Worker pools |
go: waitgroup |
WaitGroup declaration |
go: waitgroup-snippet |
WaitGroup implementation snippet |
go: mutex-snippet |
Mutex implementation snippet |
go: server-hello |
HTTP Server Hello World |
go: server-set-header |
HTTP Server Set Header |
go: server-form-post-value |
HTTP Server Get Form Post Value |
go: server-query-string |
HTTP Server Get Query String Value |
go: server-return-json |
HTTP Server return JSON snippet |
go: server-serve-image |
HTTP Server serve an image |
go: server-serve-static |
HTTP Server serve static files |
go: server-middleware |
HTTP Server Middleware |
go: server-file-upload |
HTTP Server File Upload Handler |
go: server-logging-middleware |
Server middleware for logging |
go: server-chained-middleware-sample |
Chained Middleware sample app |
go: unit-test |
Unit Test |
go: cli-args |
Read Command Line Args |
go: interface |
Define interface |
go: file-write |
Write to file |
go: write-to-log |
Write to log file |
go: env-get |
Get environment variable |
go: env-set |
Set environment variable |
- Open VS Code
- Press
Ctrl+P(orCmd+Pon macOS) - Type
ext install snp-go-basic - Press Enter
In any Go file, start typing go: to see a list of available snippets and select the one you need.
If you find any issues or have suggestions for new snippets, please open an issue on the GitHub repository.
MIT