Skip to content

Instantly share code, notes, and snippets.

@danielschmitz
Created April 15, 2021 12:26
Show Gist options
  • Save danielschmitz/168493df023ef93b4a8b0b01afedc615 to your computer and use it in GitHub Desktop.
Save danielschmitz/168493df023ef93b4a8b0b01afedc615 to your computer and use it in GitHub Desktop.
Go snipets

https://github.com/doggy8088/go-extension-pack#readme

  • Go Snippets
    • code skeleton
      • pkgm: package main and main function
      • helloweb: sample hello world webapp
    • code patterns
      • sort: custom sort.Sort interface implementation
    • function/method
      • func: function declaration
        • fmain: main function
        • finit: init function
        • go: anonymous goroutine declaration
      • meth: method declaration
    • imports
      • im: import statement
      • ims: import block
    • declarations
      • var: variable declaration
      • co: constant declaration
      • cos: constant block declaration
      • in: empty interface
      • tyi: type interface declaration
      • tys: type struct declaration
      • map: map declaration
      • gf: goroutine declaration
    • statements
      • if: if statement
      • el: else statement
      • ie: if-else statement
      • iferr: if err != nil
      • switch: switch statement
        • cs: case clause
      • for: for statement
      • forr: for range statement
      • sel: select statement
      • make: make statement
      • new: new statement
      • df: defer statement
      • ch: channel
      • pn: panic
    • fmt
      • fp: fmt.Println()
      • ff: fmt.Printf()
    • log
      • lp: log.Println()
      • lf: log.Printf()
      • lv: log.Printf() with variable content
    • net/http
      • hf: http.HandleFunc()
        • hand: http handler declaration
        • wr: http Response
        • rd: http.Redirect()
        • herr: http.Error()
      • las: http.ListenAndServe()
      • sv: http.Serve()
    • testing
      • function template
        • tdt: table driven test function
        • tf: Test function
        • bf: Benchmark function
        • ef: Example function
      • common api
        • tl: t.Log()
        • tlf: t.Logf()
        • tlv: t.Logf() with variable content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment