Snippington Golang Basic
This VSCode extension is a curation of useful Golang snippets.
30+ Snippets and more coming soon.
Most of the snippets are based on gobyexample.com.
Shortcuts
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: class |
Public Class |
go: prop |
Property |
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 |
Routine anonymous |
go: routine-basic |
Routine basic |
go: channel |
Channel |
go: channel-buffered |
Bufferred channel |
go: channel-wait-select |
Using select to wait channel |
go: channels-range |
Range over channels |
go: worker-pools |
Worker pools |
go: waitgroup |
Waitgroup |
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-middleware |
Http Server Middleware |
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 |
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 |
| |