A collection of Go snippets for the Zed IDE to improve your development speed and productivity.
This extension provides a comprehensive set of snippets for Go development, including:
- Package and import declarations
- Control structures (if, for, switch)
- Function and method declarations
- Common Go patterns
- HTTP server code
- Testing helpers
- And much more!
- Go to Extensions menu in Zed IDE
- Search for "go-snippets"
- Click "Install"
- Clone this repo:
git clone https://github.com/ayberkgezer/go-zed-snippets.git
- Go to Extensions menu in Zed IDE
- Click "Install Dev Extension"
- Select the folder you cloned
Start typing the snippet prefix (e.g., go-func) in a Go file and press Tab to expand the snippet.
| Prefix | Description |
|---|---|
go-im |
Single import statement |
go-ims |
Multiple import block |
go-co |
Single constant |
go-cos |
Multiple constants block |
go-tyf |
Type function declaration |
go-tyi |
Type interface declaration |
go-tys |
Type struct declaration |
go-pkgm |
Package main with main function |
go-func |
Function declaration |
go-var |
Single variable declaration |
go-vars |
Multiple variables block |
go-switch |
Switch statement |
go-sel |
Select statement |
go-cs |
Case clause |
go-for |
For loop |
go-forr |
For range loop |
go-ch |
Channel declaration |
go-map |
Map declaration |
go-in |
Empty interface |
go-if |
If statement |
go-el |
Else branch |
go-ie |
If-else statement |
go-iferr |
If error check |
go-fp |
fmt.Println() |
go-ff |
fmt.Printf() |
go-lp |
log.Println() |
go-lf |
log.Printf() |
go-lv |
Log variable content |
go-tl |
t.Log() for tests |
go-tlf |
t.Logf() for tests |
go-tlv |
Log variable in tests |
go-make |
make() statement |
go-new |
new() statement |
go-pn |
panic() |
go-wr |
HTTP handler parameters |
go-hf |
http.HandleFunc() |
go-hand |
HTTP handler declaration |
go-rd |
http.Redirect() |
go-herr |
http.Error() |
go-las |
http.ListenAndServe() |
go-sv |
http.Serve() |
go-go |
Anonymous goroutine |
go-gf |
Goroutine function call |
go-df |
Defer statement |
go-tf |
Test function |
go-tm |
TestMain function |
go-bf |
Benchmark function |
go-ef |
Example function |
go-tdt |
Table-driven test |
go-finit |
init function |
go-fmain |
main function |
go-meth |
Method declaration |
go-helloweb |
Hello world web app |
go-sort |
Sort implementation |
Type go-func and press Tab:
func name(param type) returnType {
// Your code here
}Type go-iferr and press Tab:
if err != nil {
return nil, err
}Type go-hand and press Tab:
func handlerName(w http.ResponseWriter, r *http.Request) {
// Your code here
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Ayberk Gezer - [email protected]