This commit is contained in:
Александр Кирюхин 2021-03-19 02:22:55 +03:00
commit 3d94211018
No known key found for this signature in database
GPG key ID: 6DF7A2910D0699E9
7 changed files with 146 additions and 0 deletions

23
.eslintrc.js Normal file
View file

@ -0,0 +1,23 @@
/**@type {import('eslint').Linter.Config} */
// eslint-disable-next-line no-undef
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'semi': [
2,
"always"
],
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
}
};

5
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}

14
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"editor.insertSpaces": false
}

15
README.md Normal file
View file

@ -0,0 +1,15 @@
# Golang snippets
Extensions with frequently used snippets for productive go development.
Extension in active development! Your contribution is always welcome :)
| Prefix| Description | Example |
| :---- |:-----------:| -------:|
| `pkg` | Package header line | `package test` |
| `tyi` | Type interface declaration | ```type test interface { }``` |
| `tys` | Type structure declaration | ```type test struct { }``` |
| `construct` | Constructor for structure type | see in action |
| `var` | Variable with type and value | `var test string = "hello"` |
| `stack` | Stack from array of types | see in action |

21
package.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "gosnippets",
"displayName": "Useful Golang snippets",
"description": "Snippets for productive work",
"version": "0.0.1",
"publisher": "Alexander NeonXP Kiryukhin",
"engines": {
"vscode": "^1.28.0"
},
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "golang",
"path": "./snippets.json"
}
]
}
}

65
snippets.json Normal file
View file

@ -0,0 +1,65 @@
{
"Interface declaration": {
"body": [
"type $1 interface {",
"\t$0",
"}"
],
"description": "go interface type",
"prefix": "tyi"
},
"Package line": {
"body": [
"package ${TM_DIRECTORY/.+\\/(.+)$/${1:/downcase}/}",
"",
"$0"
],
"description": "package header",
"prefix": "pkg"
},
"Stack from array": {
"body": [
"type ${1:name} []${2:type}",
"",
"func (s *$1) Push(item $2) {",
"\t*s = append(*s, item)",
"}",
"",
"func (s *$1) Pop() (item $2) {",
"\tif len(*s) == 0 {",
"\t\treturn",
"\t}",
"",
"\t*s, item = (*s)[:len(*s)-1], (*s)[len(*s)-1]",
"\treturn item",
"}"
],
"description": "stack from array type",
"prefix": "stack"
},
"Structure constructor": {
"body": [
"// New instance of $1 type.",
"func New${1:type}(${2}) *$1 {",
"\t$3",
"\treturn &$1{$4}",
"}"
],
"description": "constructor for structure type",
"prefix": "construct"
},
"Structure declaration": {
"body": [
"type $1 struct {",
"\t$0",
"}"
],
"description": "strucutre type",
"prefix": "tys"
},
"Variable declaration": {
"body": "var $1 $2 = $3",
"description": "variable with type and value",
"prefix": "var"
}
}