Skip to content

Commit 4e32b32

Browse files
committed
rename to guts
1 parent c1756e1 commit 4e32b32

File tree

32 files changed

+62
-60
lines changed

32 files changed

+62
-60
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# GoTs
1+
# Go Unto Ts (guts)
22

3-
[![Go Reference](https://pkg.go.dev/badge/github.com/coder/gots.svg)](https://pkg.go.dev/github.com/coder/gots)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/coder/guts.svg)](https://pkg.go.dev/github.com/coder/guts)
44

5-
`GoTS` is a tool to convert golang types to typescript for enabling a consistent type definition across the frontend and backend. It is intended to be called and customized as a library, rather than as a command line tool.
5+
`guts` is a tool to convert golang types to typescript for enabling a consistent type definition across the frontend and backend. It is intended to be called and customized as a library, rather than as a command line tool.
66

77
See the [simple example](./example/simple) for a basic usage of the library.
88
```go
@@ -30,7 +30,7 @@ interface SimpleType<T extends Comparable> {
3030

3131
# How it works
3232

33-
`GoTs` first parses a set of golang packages. The Go AST is traversed to find all the types defined in the packages.
33+
`guts` first parses a set of golang packages. The Go AST is traversed to find all the types defined in the packages.
3434

3535
These types are placed into a simple AST that directly maps to the typescript AST.
3636

bindings/vm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/dop251/goja"
77

8-
typescriptengine "github.com/coder/gots/typescript-engine"
8+
typescriptengine "github.com/coder/guts/typescript-engine"
99
)
1010

1111
type Bindings struct {
@@ -25,7 +25,7 @@ func New() (*Bindings, error) {
2525
}
2626

2727
func (b *Bindings) f(name string) (goja.Callable, error) {
28-
f, ok := goja.AssertFunction(b.vm.Get("Gots").ToObject(b.vm).Get(name))
28+
f, ok := goja.AssertFunction(b.vm.Get("guts").ToObject(b.vm).Get(name))
2929
if !ok {
3030
return nil, fmt.Errorf("%q is not a function", name)
3131
}

bindings/walk/walk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/coder/gots/bindings"
7+
"github.com/coder/guts/bindings"
88
)
99

1010
// Visitor mimics the golang ast visitor interface.

builtins.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package gots
1+
package guts
22

3-
import "github.com/coder/gots/bindings"
3+
import "github.com/coder/guts/bindings"
44

55
const (
66
builtInComparable = "Comparable"

cmd/gots/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/coder/gots"
8-
"github.com/coder/gots/config"
7+
"github.com/coder/guts"
8+
"github.com/coder/guts/config"
99
)
1010

1111
func main() {
1212
//ctx := context.Background()
13-
gen, err := gots.NewGolangParser()
13+
gen, err := guts.NewGolangParser()
1414
if err != nil {
1515
panic(err)
1616
}

config/mappings.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
package config
22

33
import (
4-
"github.com/coder/gots"
5-
"github.com/coder/gots/bindings"
4+
"github.com/coder/guts"
5+
"github.com/coder/guts/bindings"
66
)
77

8-
func OverrideLiteral(keyword bindings.LiteralKeyword) gots.TypeOverride {
8+
func OverrideLiteral(keyword bindings.LiteralKeyword) guts.TypeOverride {
99
return func() bindings.ExpressionType {
1010
return ptr(keyword)
1111
}
1212
}
1313

14-
func OverrideNullable(t gots.TypeOverride) gots.TypeOverride {
14+
func OverrideNullable(t guts.TypeOverride) guts.TypeOverride {
1515
return func() bindings.ExpressionType {
1616
return bindings.Union(t(), &bindings.Null{})
1717
}
1818
}
1919

2020
// StandardMappings is a list of standard mappings for Go types to Typescript types.
21-
func StandardMappings() map[string]gots.TypeOverride {
22-
return map[string]gots.TypeOverride{
21+
func StandardMappings() map[string]guts.TypeOverride {
22+
return map[string]guts.TypeOverride{
2323
"time.Time": OverrideLiteral(bindings.KeywordString),
2424
"time.Duration": OverrideLiteral(bindings.KeywordNumber),
2525

config/mutations.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"log/slog"
66
"reflect"
77

8-
"github.com/coder/gots"
9-
"github.com/coder/gots/bindings"
8+
"github.com/coder/guts"
9+
"github.com/coder/guts/bindings"
1010
)
1111

12-
func ExportTypes(ts *gots.Typescript) {
12+
func ExportTypes(ts *guts.Typescript) {
1313
ts.ForEach(func(key string, node bindings.Node) {
1414
switch node := node.(type) {
1515
case *bindings.Alias:
@@ -24,7 +24,7 @@ func ExportTypes(ts *gots.Typescript) {
2424
})
2525
}
2626

27-
func ReadOnly(ts *gots.Typescript) {
27+
func ReadOnly(ts *guts.Typescript) {
2828
ts.ForEach(func(key string, node bindings.Node) {
2929
switch node := node.(type) {
3030
case *bindings.Alias:
@@ -47,7 +47,7 @@ func ReadOnly(ts *gots.Typescript) {
4747
// EnumBar = "bar"
4848
// )
4949
// const MyEnums: string = ["foo", "bar"] <-- this is added
50-
func EnumLists(ts *gots.Typescript) {
50+
func EnumLists(ts *guts.Typescript) {
5151
addNodes := make(map[string]bindings.Node)
5252
ts.ForEach(func(key string, node bindings.Node) {
5353
switch node := node.(type) {

convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gots
1+
package guts
22

33
import (
44
"context"
@@ -16,7 +16,7 @@ import (
1616
"golang.org/x/tools/go/packages"
1717
"golang.org/x/xerrors"
1818

19-
"github.com/coder/gots/bindings"
19+
"github.com/coder/guts/bindings"
2020
)
2121

2222
type TypeOverride func() bindings.ExpressionType
@@ -46,7 +46,7 @@ func NewGolangParser() (*GoParser, error) {
4646
packages.NeedTypesSizes | packages.NeedSyntax | packages.NeedDeps,
4747
Tests: false,
4848
Fset: fileSet,
49-
//Dir: "/home/steven/go/src/github.com/coder/gots",
49+
//Dir: "/home/steven/go/src/github.com/coder/guts",
5050
Context: context.Background(),
5151
}
5252

@@ -269,7 +269,7 @@ func (ts *Typescript) SerializeInOrder(sort func(nodes map[string]bindings.Node)
269269
order := sort(nodes)
270270

271271
var str strings.Builder
272-
str.WriteString("// Code generated by 'gots'. DO NOT EDIT.\n\n")
272+
str.WriteString("// Code generated by 'guts'. DO NOT EDIT.\n\n")
273273

274274
for k, v := range order {
275275
obj, err := vm.ToTypescriptNode(v)

convert_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Windows tests fail because the \n\r vs \n. It's not worth trying
55
// to replace newlines for os tests. If people start using this tool on windows
66
// and are seeing problems, then we can add build tags and figure it out.
7-
package gots_test
7+
package guts_test
88

99
import (
1010
"flag"
@@ -15,8 +15,8 @@ import (
1515

1616
"github.com/stretchr/testify/require"
1717

18-
"github.com/coder/gots"
19-
"github.com/coder/gots/config"
18+
"github.com/coder/guts"
19+
"github.com/coder/guts/config"
2020
)
2121

2222
// updateGoldenFiles is a flag that can be set to update golden files.
@@ -36,7 +36,7 @@ func TestGeneration(t *testing.T) {
3636
t.Run(f.Name(), func(t *testing.T) {
3737
t.Parallel()
3838

39-
gen, err := gots.NewGolangParser()
39+
gen, err := guts.NewGolangParser()
4040
require.NoError(t, err, "new convert")
4141

4242
dir := filepath.Join(".", "testdata", f.Name())

example/simple/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"time"
66

7-
"github.com/coder/gots"
7+
"github.com/coder/guts"
88
)
99

1010
// SimpleType is a simple struct with a generic type
@@ -16,9 +16,9 @@ type SimpleType[T comparable] struct {
1616
}
1717

1818
func main() {
19-
golang, _ := gots.NewGolangParser()
19+
golang, _ := guts.NewGolangParser()
2020
// Generate the typescript types for this package
21-
_ = golang.Include("github.com/coder/gots/example/simple", true)
21+
_ = golang.Include("github.com/coder/guts/example/simple", true)
2222
// Map time.Time to string
2323
_ = golang.IncludeCustom(map[string]string{
2424
"time.Time": "string",

0 commit comments

Comments
 (0)