language-go.cson 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. '.source.go':
  2. 'package clause':
  3. 'prefix': 'pkg'
  4. 'body': "package ${1:name}"
  5. 'single import':
  6. 'prefix': 'im'
  7. 'body': 'import "${1:package}"'
  8. 'multiple imports':
  9. 'prefix': 'ims'
  10. 'body': "import (\n\t\"${1:package}\"\n)"
  11. 'single constant':
  12. 'prefix': 'co'
  13. 'body': "const ${1:name} = ${2:value}"
  14. 'multiple constants':
  15. 'prefix': 'cos'
  16. 'body': "const (\n\t${1:name} = ${2:value}\n)"
  17. 'type interface declaration':
  18. 'prefix': 'tyi'
  19. 'body': "type ${1:name} interface {\n\t$0\n}"
  20. 'type struct declaration':
  21. 'prefix': 'tys'
  22. 'body': "type ${1:name} struct {\n\t$0\n}"
  23. 'type function declaration':
  24. 'prefix': 'tyf'
  25. 'body': 'type ${1:name} func(${2:commonParam}) ${3:returnParam}'
  26. 'main package':
  27. 'prefix': 'pkgm'
  28. 'body': "package main\n\nfunc main() {\n\t$0\n}"
  29. 'function declaration':
  30. 'prefix': 'func'
  31. 'body': "func $1($2) $3 {\n\t$0\n}"
  32. 'variable declaration':
  33. 'prefix': 'var'
  34. 'body': "var ${1:name} ${2:type}"
  35. 'switch statement':
  36. 'prefix': 'switch'
  37. 'body': "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}"
  38. 'case clause':
  39. 'prefix': 'cs'
  40. 'body': "case ${1:condition}:$0"
  41. 'for statement':
  42. 'prefix': 'for'
  43. 'body': "for ${1:index} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}"
  44. 'for range statement':
  45. 'prefix': 'forr'
  46. 'body': "for ${1:var} := range ${2:var} {\n\t$0\n}"
  47. 'channel declaration':
  48. 'prefix': 'ch'
  49. 'body': "chan ${1:type}"
  50. 'map declaration':
  51. 'prefix': 'map'
  52. 'body': "map[${1:type}]${2:type}"
  53. 'empty interface':
  54. 'prefix': 'in'
  55. 'body': "interface{}"
  56. 'if statement':
  57. 'prefix': 'if'
  58. 'body': "if ${1:condition} {\n\t$0\n}"
  59. 'else branch':
  60. 'prefix': 'el'
  61. 'body': "else {\n\t$0\n}"
  62. 'if else statement':
  63. 'prefix': 'ie'
  64. 'body': "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}"
  65. 'if err != nil':
  66. 'prefix': 'iferr'
  67. 'body': "if err != nil {\n\t${1:return}\n}"
  68. 'fmt.Println':
  69. 'prefix': 'fp'
  70. 'body': "fmt.Println(\"$1\")"
  71. 'fmt.Printf':
  72. 'prefix': 'ff'
  73. 'body': "fmt.Printf(\"$1\", ${2:var})"
  74. 'log.Println':
  75. 'prefix': 'lp'
  76. 'body': "log.Println(\"$1\")"
  77. 'log.Printf':
  78. 'prefix': 'lf'
  79. 'body': "log.Printf(\"$1\", ${2:var})"
  80. 'log variable content':
  81. 'prefix': 'lv'
  82. 'body': "log.Printf(\"${1:var}: %#+v\\\\n\", ${1:var})"
  83. 'make(...)':
  84. 'prefix': 'make'
  85. 'body': "make(${1:type}, ${2:0})"
  86. 'new(...)':
  87. 'prefix': 'new'
  88. 'body': "new(${1:type})"
  89. 'panic(...)':
  90. 'prefix': 'pn'
  91. 'body': "panic(\"$0\")"
  92. 'http ResponseWriter *Request':
  93. 'prefix': 'wr'
  94. 'body': "${1:w} http.ResponseWriter, ${2:r} *http.Request"
  95. 'http Context ResponseWriter *Request':
  96. 'prefix': 'cwr'
  97. 'body': "${1:c} context.Context, ${2:w} http.ResponseWriter, ${3:r} *http.Request"
  98. 'http.HandleFunc':
  99. 'prefix': 'hf'
  100. 'body': "${1:http}.HandleFunc(\"${2:/}\", ${3:handler})"
  101. 'http handler declaration':
  102. 'prefix': 'hand'
  103. 'body': "func $1(${2:w} http.ResponseWriter, ${3:r} *http.Request) {\n\t$0\n}"
  104. 'http.Redirect':
  105. 'prefix': 'rd'
  106. 'body': "http.Redirect(${1:w}, ${2:r}, \"${3:/}\", ${4:http.StatusFound})"
  107. 'http.Error':
  108. 'prefix': 'herr'
  109. 'body': "http.Error(${1:w}, ${2:err}.Error(), ${3:http.StatusInternalServerError})"
  110. 'http.ListenAndServe':
  111. 'prefix': 'las'
  112. 'body': "http.ListenAndServe(\"${1::8080}\", ${2:nil})"
  113. 'http.Serve':
  114. 'prefix': 'sv'
  115. 'body': "http.Serve(\"${1::8080}\", ${2:nil})"
  116. 'goroutine anonymous function':
  117. 'prefix': 'go'
  118. 'body': 'go func($1) {\n\t$2\n}($0)'
  119. 'goroutine function':
  120. 'prefix': 'gf'
  121. 'body': 'go ${1:func}($0)'
  122. 'defer statement':
  123. 'prefix': 'df'
  124. 'body': "defer ${1:func}($0)"
  125. 'test function':
  126. 'prefix': 'tf'
  127. 'body': "func Test$1(t *testing.T) {\n\t$0\n}"
  128. 'go template':
  129. 'prefix': 'got'
  130. 'body': """
  131. package ${1:main}
  132. import (
  133. "${2:fmt}"
  134. )
  135. func ${1:main}() {
  136. $3
  137. }
  138. """