This commit is contained in:
2024-04-30 07:08:23 +02:00
commit a711247971
2043 changed files with 16874 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: benchmark
# key: bench
# contributor : @atotto
# --
func Benchmark$1(b *testing.B) {
for i := 0; i < b.N; i++ {
$0
}
}

6
snippets/go-mode/const Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode:snippet -*-
# name: const
# key: const
# --
const ${1:name type} = ${2:val}
$0

7
snippets/go-mode/const( Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode:snippet -*-
# name: const (...)
# key: const
# --
const (
${1:name type} = ${2:val}
)

6
snippets/go-mode/dd Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: debug fmt.Printf
# key: dd
# --
fmt.Printf("%+v\n", $1) // output for debug
$0

6
snippets/go-mode/default Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: default
# key: def
# --
default:
$0

7
snippets/go-mode/else Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: else
# key: el
# --
else {
$0
}

8
snippets/go-mode/error Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: error
# key: err
# contributor : @atotto
# --
if err != nil {
$0
}

8
snippets/go-mode/example Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: example
# key: example
# contributor : @atotto
# --
func Example$1() {
$0
}

7
snippets/go-mode/for Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode:snippet -*-
# name: for
# key: for
# --
for $1 {
$0
}

View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: for range
# key: range
# contributor : @atotto
# --
for ${3:key}, ${2:value} := range ${1:target} {
$0
}

8
snippets/go-mode/func Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: func
# key: func
# --
// $1 ${4:...}
func ${1:name}(${2:args}) $3 {
$0
}

7
snippets/go-mode/if Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: if
# key: if
# --
if $1 {
$0
}

7
snippets/go-mode/iferr Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: if error
# key: iferr
# --
if err != $1 {
$0
}

6
snippets/go-mode/import Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode:snippet -*-
# name: import
# key: imp
# --
import "$1"
$0

7
snippets/go-mode/import( Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode:snippet -*-
# name: import (...)
# key: imp
# --
import (
"$0"
)

7
snippets/go-mode/init Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: func init()
# key: init
# --
func init() {
$0
}

7
snippets/go-mode/lambda Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: lambda func
# key: lambda
# --
func(${1:args}) $2 {
$0
}()

8
snippets/go-mode/main Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: func main()
# condition: (progn (forward-line 0) (not (and (eq (point-min) (point)) (looking-at-p "package"))))
# key: main
# --
func main() {
$0
}

5
snippets/go-mode/map Normal file
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: map
# key: map
# --
map[${1:type}]${2:type}

9
snippets/go-mode/method Normal file
View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: method
# key: mthd
# contributor: @Kunde21
# --
// $2 ${5:...}
func (${1:recv}) ${2:name}(${3:args}) $4 {
$0
}

View File

@@ -0,0 +1,12 @@
# -*- mode: snippet -*-
# name: parallel_benchmark
# key: parbench
# contributor : @kostya-sh
# --
func Benchmark$1(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
$0
}
})
}

6
snippets/go-mode/printf Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: fmt.Printf(...)
# key: pr
# --
fmt.Printf("${1:%s}\n", ${2:args})
$0

8
snippets/go-mode/select Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: select
# key: sel
# --
select {
case $1:
$0
}

8
snippets/go-mode/switch Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: switch
# key: sw
# --
switch $1 {
case $2:
$0
}

8
snippets/go-mode/test Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: test
# key: at
# contributor : @atotto
# --
func Test$1(t *testing.T) {
$0
}

21
snippets/go-mode/testmain Normal file
View File

@@ -0,0 +1,21 @@
# -*- mode: snippet -*-
# name: testmain
# key: testmain
# contributor : @atotto
# --
func TestMain(m *testing.M) {
setup()
ret := m.Run()
if ret == 0 {
teardown()
}
os.Exit(ret)
}
func setup() {
$1
}
func teardown() {
$2
}

7
snippets/go-mode/type Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: type
# key: type
# --
type $1 $2 {
$0
}

6
snippets/go-mode/var Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: var
# key: var
# --
var ${1:name} ${2:type}
$0

7
snippets/go-mode/var( Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: var (...)
# key: var
# --
var (
${1:name} ${2:type}
)