From 4cbb007fd03cea6c214c99a3989a4e76f1a441c5 Mon Sep 17 00:00:00 2001 From: weidaolee Date: Sat, 16 Sep 2023 16:02:14 +0800 Subject: [PATCH] fix(go-mode): Introduces consistent formatting changes to Go snippets **Summary:** This pull request introduces consistent formatting changes to various Go code snippets in the 'go-mode' directory. The changes include: - Adding spaces between function parameters and return types. - Formatting import statements to use parentheses for multiple imports. - Updating struct snippets to include a name for the struct type. - Updating the 'switch' snippet to include an expression. - Adding `type` for creating a new struct or interface. **Changes Made:** - In 'go-mode/f' and 'go-mode/func', added spaces between function parameters and return types to follow go convention. - In 'go-mode/method', added spaces between function parameters and return types to follow go convention. - In 'go-mode/imp' and 'go-mode/import', reformatted import statements to use parentheses for multiple imports. - In 'go-mode/struct', added a name for the struct type for clarity. - Add a new file `go-mode/type` for creating a new struct or interface. - In 'go-mode/switch', updated the 'switch' snippet to include an expression for better usage. These changes improve code readability and maintain consistency throughout the 'go-mode' snippets. **Related Issues:** None --- go-mode/f | 2 +- go-mode/fm | 2 +- go-mode/func | 2 +- go-mode/imp | 4 +++- go-mode/import | 4 +++- go-mode/method | 2 +- go-mode/struct | 2 +- go-mode/switch | 4 ++-- go-mode/type | 6 ++++++ 9 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 go-mode/type diff --git a/go-mode/f b/go-mode/f index 4a1175ce..0b5782bb 100644 --- a/go-mode/f +++ b/go-mode/f @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: func ...(...) ... { ... } # -- -func ${1:name}(${2:args})${3: return type} { +func ${1:name}(${2:args}) ${3:return type}{ `%`$0 } \ No newline at end of file diff --git a/go-mode/fm b/go-mode/fm index a35ace16..612a0dbc 100644 --- a/go-mode/fm +++ b/go-mode/fm @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: func (target) name(args) (results) { ... } # -- -func (${1:target}) ${2:name}(${3:args})${4: return type} { +func (${1:target}) ${2:name}(${3:args}) ${4:return type}{ $0 } \ No newline at end of file diff --git a/go-mode/func b/go-mode/func index 4a1175ce..0b5782bb 100644 --- a/go-mode/func +++ b/go-mode/func @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: func ...(...) ... { ... } # -- -func ${1:name}(${2:args})${3: return type} { +func ${1:name}(${2:args}) ${3:return type}{ `%`$0 } \ No newline at end of file diff --git a/go-mode/imp b/go-mode/imp index d23663e4..70eb8ed6 100644 --- a/go-mode/imp +++ b/go-mode/imp @@ -1,4 +1,6 @@ # -*- mode: snippet -*- # name: import # -- -import ${1:package}$0 \ No newline at end of file +import ( + ${1:package}$0 +) \ No newline at end of file diff --git a/go-mode/import b/go-mode/import index d23663e4..70eb8ed6 100644 --- a/go-mode/import +++ b/go-mode/import @@ -1,4 +1,6 @@ # -*- mode: snippet -*- # name: import # -- -import ${1:package}$0 \ No newline at end of file +import ( + ${1:package}$0 +) \ No newline at end of file diff --git a/go-mode/method b/go-mode/method index a35ace16..612a0dbc 100644 --- a/go-mode/method +++ b/go-mode/method @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: func (target) name(args) (results) { ... } # -- -func (${1:target}) ${2:name}(${3:args})${4: return type} { +func (${1:target}) ${2:name}(${3:args}) ${4:return type}{ $0 } \ No newline at end of file diff --git a/go-mode/struct b/go-mode/struct index d0aa7cdf..a10a964c 100644 --- a/go-mode/struct +++ b/go-mode/struct @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # name: type ... struct { ... } # -- -type $1 struct { +type ${1:name} struct { `%`$0 } \ No newline at end of file diff --git a/go-mode/switch b/go-mode/switch index 29ef0e85..9ec6afe1 100644 --- a/go-mode/switch +++ b/go-mode/switch @@ -3,7 +3,7 @@ # key: switch # uuid: switch # -- -switch { - case ${1:cond}: +switch ${1:express}{ + case ${2:cond}: $0 } \ No newline at end of file diff --git a/go-mode/type b/go-mode/type new file mode 100644 index 00000000..e9e03331 --- /dev/null +++ b/go-mode/type @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: type ... ... { ... } +# -- +type ${1:name} ${2:struct | interface} { + `%`$0 +} \ No newline at end of file