[ { "repoUrl": "https://github.com/joshvera/go.git", "language": "go", "fileExt": ".go", "templateText": "package main\n", "syntaxes": [ { "syntax": "single-import-declarations", "insert": "import \"net/http\"\nimport . \"some/dsl\"\nimport alias \"some/package\"", "replacement": "import \"foo/bar\"\nimport . \"types/dsl\"\nimport alias \"awesome/packages\"" }, { "syntax": "grouped-import-declarations", "insert": "import (\n\"net/http\"\n . \"some/dsl\"\n alias \"some/package\"\n)", "replacement": "import (\n\"net/socket\"\n . \"types/dsl\"\n alias \"awesome/package\"\n)" }, { "syntax": "int-literals", "insert": "const (\na = 1, b = 2, c = 3\n)", "replacement": "const (\na = 4, b = 5, c = 6\n)" }, { "syntax": "assignment-statements", "insert": "a = 1\nb, c += 2, 3\nd *= 3\ne += 1", "replacement": "x = 1\ny, c += 2, 3\nz *= 3\nh += 1" }, { "syntax": "if-statements", "insert": "if a() {\nb()\n}\nif a := b(); c {\nd()\n}\nif a() {\nb()\n} else {\nc()\n}", "replacement": "if x() {\nb()\n}\nif y := b(); c {\nd()\n}\nif z() {\nb()\n} else {\nc()\n}" }, { "syntax": "short-var-declarations", "insert": "a, b := 1, 2", "replacement": "x, y := 3, 4" }, { "syntax": "call-expressions", "insert": "x(b, c...)\ny(b, c,)\nz(b,c...,)", "replacement": "a(b, c...)\nb(b, c,)\nc(b,c...,)" }, { "syntax": "function-literals", "insert": "const s1 = func(s string) (int, int) {\nreturn 1, 2\n}", "replacement": "const s1 = func(b int) (string, string) {\nreturn 1, 2\n}" }, { "syntax": "const-declarations-without-types", "insert": "const zero = 0", "replacement": "const one, two = 1, 2" }, { "syntax": "const-declarations-with-types", "insert": "const zero int = 0", "replacement": "const one, two uiint64 = 1, 2" }, { "syntax": "var-declarations-without-types", "insert": "var zero = 0", "replacement": "var one, two = 1, 2" }, { "syntax": "var-declarations-with-types", "insert": "var zero int = 0\nvar one, two uint64 = 1, 2", "replacement": "var a int = 0\n var b, c uint64 = 1, 2" }, { "syntax": "var-declarations-with-no-expressions", "insert": "var zero int\nvar one, two uint64", "replacement": "var a int\nvar b, c uint64" }, { "syntax": "grouped-var-declarations", "insert": "var (\nzero = 0\none = 1\n)", "replacement": "var (\na = 0\nb = 1\n)" }, { "syntax": "switch-statements", "insert": "switch { case x < y: f1()\ncase x < z: g()\ncase x == 4: h()\n}", "replacement": "switch { case a < b: f1()\ncase c < d: g()\ncase e == 4: f()\n}" }, { "syntax": "type-switch-statements", "insert": "switch e.(type) {\n case []Person:\n a()\n case *Dog:\n break\n}", "replacement": "switch b.(type) {\n case []Person:\n a()\n case *Dog:\n break\n}" }, { "syntax": "select-statements", "insert": "select {\n case x := <-c:\n println(x)\n case y <- c:\n println(5)\n case <-time.After(1):\n println(6)\n default:\n return\n}", "replacement": "select {\n case a := <-c:\n println(x)\n case b <- c:\n println(5)\n case <-time.After(2):\n println(6)\n default:\n return\n}" }, { "syntax": "go-and-defer-statements", "insert": "defer x.y()\ngo x.y()", "replacement": "defer a.b()\ngo c.d()" }, { "syntax": "label-statements", "insert": "{\n insert_label:\n}", "replacement": "{\n replacement_label:\n}" }, { "syntax": "for-statements", "insert": "for { case x < y: f1()\ncase x < z: g()\ncase x == 4: h()\n}", "replacement": "func main() { for { a() goto loop }\nloop: for i := 0; i < 5; i++\n{ a()\nbreak loop\n}\nloop2: for ; i < 10; i++ \n{ \na()\ncontinue loop2\n}\nfor ;; { a() continue }\nfor x := range y { a(x)\nbreak }\n}" }, { "syntax": "function-declarations", "insert": "func f1() {}\nfunc f2(a int, b, c, d string) int {}\nfunc f2() (int, error) {}\nfunc f2() (result int, err error) {}", "replacement": "func fa() {}\nfunc fb(a int, b, c, d string) int {}\nfunc fc() (int, error) {}\nfunc fd() (result int, err error) {}" }, { "syntax": "single-line-function-declarations", "insert": "func f1() { a() }\nfunc f2() { a(); b() }\nfunc f3() { a(); b(); }", "replacement": "func g1() { a() }\nfunc g2() { a(); b() }\nfunc g3() { a(); b(); }" }, { "syntax": "variadic-function-declarations", "insert": "func f1(a ...*int) {}\nfunc f2(...int) {}\nfunc f3(a, ...bool) {}", "replacement": "func g1(a ...*int) {}\nfunc g2(...int) {}\nfunc g3(a, ...bool) {}" }, { "syntax": "method-declarations", "insert": "func (self Person) Equals(other Person) bool {}", "replacement": "func (self Num) Equals(other Num) bool {}" }, { "syntax": "type-declarations", "insert": "type a b\ntype (\n a b\n c d\n )", "replacement": "type a' b'\ntype (\n a' b'\n c' d'\n )" }, { "syntax": "const-with-implicit-values", "insert": "const (\n zero = iota\n one\n two\n )", "replacement": "const (\n a = iota\n b\n c\n )" }, { "syntax": "constructors", "insert": "make(chan<- int)\nmake(chan<- int, (new - old))\nmake(chan<- int, 5, 10)\n new(map[string]string)", "replacement": "make(chan<- string)\nmake(chan<- string, (new - old))\nmake(chan<- string, 7, 11)\n new(map[int]int)" }, { "syntax": "selector-expressions", "insert": "a.b.c()", "replacement": "x.y.z()" }, { "syntax": "indexing-expressions", "insert": "a[1]\n b[:]\n c[1:]\n d[1:2]\n e[:2:3]\n f[1:2:3]", "replacement": "z[:2]\n y[:1]\n x[1:]\n d[1:2]\n e[:2:3]\n f[1:2:3]" }, { "syntax": "type-assertion-expressions", "insert": "x.(z.Person)", "replacement": "b.(c.Dog)" }, { "syntax": "type-conversion-expressions", "insert": "[]a.b(c.d)\n ([]a.b)(c.d)\n e.f(g)\n (e.f)(g)", "replacement": "[]x.y(z.e)\n ([]f.g)(h.i)\n j.k(l)\n (m.n)(o)" }, { "syntax": "unary-expressions", "insert": "!<-a\n*foo()", "replacement": "!<-b\n*bar()" }, { "syntax": "float-literals", "insert": "f1 = 1.5\nf2 = 1.5e100\nf3 = 1.5e+50\nf4 = 1.5e-5\nf5 = .5e-50", "replacement": "f2 = 1.5\nf3 = 1.5e100\nf4 = 1.5e+50\nf5 = 1.5e-5\nf6 = .5e-50" }, { "syntax": "rune-literals", "insert": "const (\na = '0'\nb = '\\''\nc = '\\\\'\nc = '\\n'\nc = '\\u0000'\nc = '\\U01234567'\n)", "replacement": "const (\na = '1'\nb = '\\n''\nc = '\\u0011'\nc = '\\\\'\nc = '\\u0022'\nc = '\\U01234568'\n)" }, { "syntax": "imaginary-literals", "insert": "const (\na = 01i\nb = 1.e+100i\n)", "replacement": "const (\na = 02i\nb = 1.e+103i\n)" }, { "syntax": "string-literals", "insert": "const (\na = \"0\"\nb = \"hello world\"\n)", "replacement": "const (\na = \"2\"\nb = \"hi\"\n)" }, { "syntax": "slice-literals", "insert": "const s1 = []string{}\nconst s2 = []string{\"hi\"}\nconst s3 = []string{\n\"hi\",\n \"hello\",\n}", "replacement": "const s1 = []string{\"sup\"}\nconst s2 = []string{\"hello\"}\nconst s3 = []string{\n\"bar\",\n \"baz\",\n}" }, { "syntax": "array-with-implicit-length", "insert": "const a1 = [...]int{1, 2, 3}", "replacement": "const a1 = [...]int{4,5,6}" }, { "syntax": "map-literals", "insert": "const s = map[string]string{\n\"hi\": \"hello\",\n\"bye\": \"goodbye\",\n}", "replacement": "const s = map[string]int{\n\"foo\": \"bar\",\n\"baz\": \"hello\",\n}" }, { "syntax": "struct-literals", "insert": "const s1 = Person{\nname: \"Frank\",\nAge: \"5 months\",\n}\nconst s2 = struct{i int;}{i: 5}\nconst s3 = time.Time{}", "replacement": "const s1 = Dog{\nname: \"Frank\",\nAge: \"5 months\",\n}\nconst s2 = struct{i float;}{j: 6}\nconst s3 = time.Month{}" }, { "syntax": "send-statements", "insert": "foo <- 5", "replacement": "bar <- 6" }, { "syntax": "increment-decrement-statements", "insert": "i++\nj--", "replacement": "foo++\nx++" }, { "syntax": "qualified-types", "insert": "type a b.c", "replacement": "type x y.z" }, { "syntax": "array-types", "insert": "type a [2+2]x", "replacement": "type a [1+1]y" }, { "syntax": "slice-types", "insert": "type a []b\ntype c [][]d", "replacement": "type a [][]p\ntype c []y" }, { "syntax": "struct-types", "insert": "type s1 struct {}\ntype s2 struct { Person }\ntype s3 struct {\nf, g int\n}\ntype s4 struct {\np.s1\n h int `json:\"h\"`\n}", "replacement": "type t1 struct {}\ntype t2 struct { Person }\ntype t3 struct {\nf, g int\n}\ntype t4 struct {\np.s1\n h int `json:\"h\"`\n}" }, { "syntax": "interface-types", "insert": "type i1 interface {}\ntype i2 interface { io.Reader }\ntype i3 interface {\ni1\nio.Reader\n SomeMethod(s string) error\n}", "replacement": "type j1 interface {}\ntype j2 interface { io.Reader }\ntype j3 interface {\ni1\nio.Reader\n SomeMethod(s string) error\n}" }, { "syntax": "map-types", "insert": "type m1 map[string]error", "replacement": "type m1 map[int]error" }, { "syntax": "pointer-types", "insert": "type (\np1 *string\np2 **p1\n)", "replacement": "type (\np1 *int\np2 **p3\n)" }, { "syntax": "channel-types", "insert": "type (\nc1 chan<- chan int\nc2 chan<- chan<- struct{}\nc3 chan<- <-chan int\n)", "replacement": "type (\nc2 chan<- chan string\nc3 chan<- chan<- struct{}\nc4 chan<- <-chan string\n)" }, { "syntax": "function-types", "insert": "type (\na func(int) int\nb func(int, string) (bool, error)\n)", "replacement": "type (\nx func(string) string\ny func(string, int) (chan, error)\n)" } ] } ]