{
  "schema": 1,
  "id": "ext.go",
  "name": "Go",
  "version": "1.0.4",
  "category": "language",
  "description": "Go with backtick strings, channel operators and a go run/test runner.",
  "author": "Lumen",
  "icon": "Go",
  "color": "#00add8",
  "license": "MIT",
  "minAppVersion": "0.5.0",
  "keywords": [
    "go",
    "golang",
    "gopls",
    "delve"
  ],
  "readme": "# Go\n\nGo support for Lumen: syntax, snippets, `gopls`, Delve, project detection for\nGo modules and a project template.\n\n## Contents\n\n- **Language** `.go`: backtick strings, channel operators (`<-`, `:=`, `&^`),\n  capitalization as a type, 13 snippets from `iferr` to the table-driven test\n- **Language server** `gopls` with `staticcheck`, `gofumpt` and suggestions from\n  packages that are not yet imported\n- **Debugger** Delve\n- **Project kind** Go module (`go.mod`, `go.work`) with build, test and tidy\n  tasks; `go get` adds dependencies\n- **Template** module as a program (`cmd/`) or as a library\n\n## Tools\n\n```sh\ngo install golang.org/x/tools/gopls@latest\ngo install github.com/go-delve/delve/cmd/dlv@latest\n```\n\nIf `gopls` is missing, Lumen offers to install it when a `.go` file is opened.\n",
  "settings": [],
  "pages": [],
  "agents": [],
  "views": [],
  "commands": [],
  "addon": {
    "schema": 1,
    "languages": [
      {
        "id": "go",
        "name": "Go",
        "extensions": [
          ".go"
        ],
        "filenames": [
          "go.mod",
          "go.sum"
        ],
        "icon": "Go",
        "color": "#00add8",
        "capitalizedAsType": true,
        "comments": {
          "line": "//",
          "block": [
            "/*",
            "*/"
          ]
        },
        "controls": [
          "if",
          "else",
          "for",
          "range",
          "switch",
          "case",
          "default",
          "break",
          "continue",
          "return",
          "goto",
          "fallthrough",
          "select",
          "defer"
        ],
        "keywords": [
          "package",
          "import",
          "func",
          "var",
          "const",
          "type",
          "struct",
          "interface",
          "map",
          "chan",
          "go",
          "unsafe"
        ],
        "types": [
          "bool",
          "string",
          "int",
          "int8",
          "int16",
          "int32",
          "int64",
          "uint",
          "uint8",
          "uint16",
          "uint32",
          "uint64",
          "uintptr",
          "byte",
          "rune",
          "float32",
          "float64",
          "complex64",
          "complex128",
          "error",
          "any"
        ],
        "constants": [
          "true",
          "false",
          "nil",
          "iota"
        ],
        "builtins": [
          "len",
          "cap",
          "make",
          "new",
          "append",
          "copy",
          "delete",
          "close",
          "panic",
          "recover",
          "print",
          "println",
          "min",
          "max",
          "clear",
          "fmt",
          "errors"
        ],
        "strings": [
          {
            "start": "`",
            "end": "`",
            "multiline": true,
            "escapes": false
          },
          {
            "start": "\"",
            "escapes": true
          },
          {
            "start": "'",
            "escapes": true
          }
        ],
        "operators": "^(?:<-|:=|\\.\\.\\.|&\\^|[+\\-*/%=<>!&|^~])",
        "snippets": [
          {
            "label": "main",
            "detail": "main package",
            "body": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"$0\")\n}"
          },
          {
            "label": "func",
            "detail": "Function",
            "body": "func ${name}(${arg} ${T}) ${R} {\n\t$0\n}"
          },
          {
            "label": "iferr",
            "detail": "Error check",
            "body": "if err != nil {\n\treturn err\n}$0"
          },
          {
            "label": "struct",
            "detail": "Struct",
            "body": "type ${Name} struct {\n\t${Feld} ${T}\n}"
          },
          {
            "label": "iface",
            "detail": "Interface",
            "body": "type ${Name} interface {\n\t${Methode}() ${error}\n}$0"
          },
          {
            "label": "meth",
            "detail": "Method",
            "body": "func (${r} *${Typ}) ${Name}() ${error} {\n\t$0\n}"
          },
          {
            "label": "forr",
            "detail": "for…range",
            "body": "for ${i}, ${v} := range ${liste} {\n\t$0\n}"
          },
          {
            "label": "errf",
            "detail": "Error with context",
            "body": "if err != nil {\n\treturn fmt.Errorf(\"${kontext}: %w\", err)\n}$0"
          },
          {
            "label": "go",
            "detail": "Goroutine with WaitGroup",
            "body": "var wg sync.WaitGroup\nwg.Add(1)\ngo func() {\n\tdefer wg.Done()\n\t$0\n}()\nwg.Wait()"
          },
          {
            "label": "sel",
            "detail": "select",
            "body": "select {\ncase ${v} := <-${ch}:\n\t$0\ncase <-ctx.Done():\n\treturn ctx.Err()\n}"
          },
          {
            "label": "ctx",
            "detail": "Context with timeout",
            "body": "ctx, cancel := context.WithTimeout(context.Background(), ${5}*time.Second)\ndefer cancel()$0"
          },
          {
            "label": "test",
            "detail": "Test",
            "body": "func Test${Name}(t *testing.T) {\n\t$0\n}"
          },
          {
            "label": "table",
            "detail": "Table-driven test",
            "body": "func Test${Name}(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\twant ${int}\n\t}{\n\t\t{\"${fall}\", ${1}},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\t$0\n\t\t})\n\t}\n}"
          }
        ],
        "indentUnit": 4,
        "run": [
          {
            "label": "go run",
            "command": "go",
            "args": [
              "run",
              "${file}"
            ]
          },
          {
            "label": "go run .",
            "command": "go",
            "args": [
              "run",
              "."
            ]
          },
          {
            "label": "go test",
            "command": "go",
            "args": [
              "test",
              "./..."
            ]
          },
          {
            "label": "go vet",
            "command": "go",
            "args": [
              "vet",
              "./..."
            ]
          }
        ],
        "debug": [
          "delve"
        ],
        "lsp": [
          {
            "label": "gopls",
            "command": "gopls",
            "args": [],
            "languageId": "go",
            "rootMarkers": [
              "go.work",
              "go.mod",
              ".git"
            ],
            "settings": {
              "gopls": {
                "usePlaceholders": true,
                "staticcheck": true,
                "gofumpt": true,
                "completeUnimported": true,
                "deepCompletion": true,
                "matcher": "Fuzzy",
                "completionBudget": "0s",
                "symbolScope": "all"
              }
            },
            "install": "go install golang.org/x/tools/gopls@latest",
            "package": {
              "type": "go",
              "module": "golang.org/x/tools/gopls@latest"
            },
            "systemPackages": {
              "pacman": "gopls",
              "apt": "gopls",
              "dnf": "golang-x-tools-gopls",
              "brew": "gopls"
            }
          }
        ]
      }
    ],
    "themes": [],
    "commands": [],
    "events": [],
    "templates": [
      {
        "id": "go-module",
        "name": "templates.lang.goModule",
        "description": "templates.lang.goDescription",
        "languageId": "go",
        "kindId": "go",
        "icon": "Go",
        "color": "#00add8",
        "fields": [
          {
            "id": "module",
            "label": "templates.fields.modulePath",
            "default": "github.com/benutzer/{{slug}}",
            "pattern": "[\\w.\\-/]+",
            "mono": true,
            "section": "templates.sections.project"
          },
          {
            "id": "description",
            "label": "templates.fields.description",
            "placeholder": "templates.fields.descriptionPlaceholder",
            "required": false,
            "section": "templates.sections.project"
          },
          {
            "id": "go",
            "label": "templates.lang.goVersion",
            "type": "select",
            "section": "templates.sections.build",
            "choices": [
              {
                "value": "1.23",
                "label": "1.23"
              },
              {
                "value": "1.24",
                "label": "1.24"
              },
              {
                "value": "1.22",
                "label": "1.22"
              }
            ]
          },
          {
            "id": "type",
            "label": "templates.fields.type",
            "type": "select",
            "section": "templates.sections.build",
            "choices": [
              {
                "value": "cmd",
                "label": "templates.lang.programCmd"
              },
              {
                "value": "lib",
                "label": "templates.fields.library"
              }
            ]
          }
        ],
        "open": "{{#if type=lib}}{{slug|snake}}.go{{/if}}{{#unless type=lib}}cmd/{{slug}}/main.go{{/unless}}",
        "setup": [
          {
            "label": "go mod tidy",
            "command": "go",
            "args": [
              "mod",
              "tidy"
            ]
          }
        ],
        "files": [
          {
            "path": "go.mod",
            "content": "module {{module}}\n\ngo {{go}}\n"
          },
          {
            "path": "{{slug|snake}}.go",
            "when": {
              "field": "type",
              "equals": "lib"
            },
            "content": "// Package {{slug|alnum}} — {{description}}.\npackage {{slug|alnum}}\n\n// Add addiert zwei Zahlen.\nfunc Add(a, b int) int {\n\treturn a + b\n}\n"
          },
          {
            "path": "{{slug|snake}}_test.go",
            "when": {
              "field": "type",
              "equals": "lib"
            },
            "content": "package {{slug|alnum}}\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {\n\tif got := Add(2, 3); got != 5 {\n\t\tt.Fatalf(\"Add(2, 3) = %d, erwartet 5\", got)\n\t}\n}\n"
          },
          {
            "path": "cmd/{{slug}}/main.go",
            "when": {
              "field": "type",
              "notEquals": "lib"
            },
            "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"{{module}}/internal/greet\"\n)\n\nfunc main() {\n\tfmt.Println(greet.Hello(\"{{name}}\"))\n}\n"
          },
          {
            "path": "internal/greet/greet.go",
            "when": {
              "field": "type",
              "notEquals": "lib"
            },
            "content": "package greet\n\n// Hello returns a greeting.\nfunc Hello(who string) string {\n\treturn \"Hello from \" + who + \"!\"\n}\n"
          },
          {
            "path": "internal/greet/greet_test.go",
            "when": {
              "field": "type",
              "notEquals": "lib"
            },
            "content": "package greet\n\nimport \"testing\"\n\nfunc TestHello(t *testing.T) {\n\tif got := Hello(\"x\"); got != \"Hello from x!\" {\n\t\tt.Fatalf(\"unexpected: %q\", got)\n\t}\n}\n"
          },
          {
            "path": "README.md",
            "when": {
              "field": "type",
              "notEquals": "lib"
            },
            "content": "# {{name}}\n\n```bash\ngo run ./cmd/{{slug}}\ngo test ./...\n```\n"
          },
          {
            "path": ".gitignore",
            "content": "bin/\n*.test\n.lumen/\n"
          }
        ]
      }
    ],
    "projectKinds": [
      {
        "id": "go",
        "name": "templates.lang.goModule",
        "icon": "Go",
        "color": "#00add8",
        "markers": [
          "go.mod",
          "go.work"
        ],
        "priority": 10,
        "languageIds": [
          "go"
        ],
        "dependencies": {
          "manager": "Go-Module",
          "placeholder": "github.com/spf13/cobra",
          "hint": "templates.lang.goHint",
          "command": "go",
          "args": [
            "get",
            "{spec}"
          ],
          "label": "go get {name}",
          "id": "go:get"
        },
        "tasks": [
          {
            "id": "build",
            "label": "templates.tasks.build",
            "command": "go",
            "args": [
              "build",
              "./..."
            ],
            "group": "build"
          },
          {
            "id": "run",
            "label": "templates.tasks.run",
            "command": "go",
            "args": [
              "run",
              "."
            ],
            "group": "run",
            "forEachDir": {
              "dir": "cmd",
              "label": "templates.tasks.runTarget",
              "args": [
                "run",
                "./cmd/{dir}"
              ],
              "limit": 4
            }
          },
          {
            "id": "test",
            "label": "templates.tasks.tests",
            "command": "go",
            "args": [
              "test",
              "./..."
            ],
            "group": "test"
          },
          {
            "id": "vet",
            "label": "go vet",
            "command": "go",
            "args": [
              "vet",
              "./..."
            ],
            "group": "test"
          },
          {
            "id": "tidy",
            "label": "go mod tidy",
            "command": "go",
            "args": [
              "mod",
              "tidy"
            ],
            "group": "other"
          },
          {
            "id": "download",
            "label": "templates.lang.downloadModules",
            "command": "go",
            "args": [
              "mod",
              "download"
            ],
            "group": "build"
          },
          {
            "id": "update",
            "label": "templates.tasks.updateDeps",
            "command": "go",
            "args": [
              "get",
              "-u",
              "./..."
            ],
            "group": "other"
          }
        ],
        "facts": [
          {
            "label": "Module",
            "file": "go.mod",
            "pattern": "^module\\s+(\\S+)",
            "role": "name"
          },
          {
            "label": "Go",
            "file": "go.mod",
            "pattern": "^go\\s+(\\S+)"
          }
        ],
        "buildFile": "go.mod",
        "dependencyScan": {
          "file": "go.mod",
          "pattern": "^\\s*(\\S+)\\s+(v\\S+)(\\s+//\\s*indirect)?"
        }
      }
    ],
    "snippets": [],
    "id": "ext.go",
    "name": "Go",
    "version": "1.0.4",
    "description": "Go with backtick strings, channel operators and a go run/test runner.",
    "author": "Lumen",
    "icon": "Go",
    "color": "#00add8",
    "category": "language"
  }
}
