https://github.com/zmitry/go2typings
convert golang structs to typescript interfaces or swagger spec
https://github.com/zmitry/go2typings
golang typescript typings
Last synced: 6 months ago
JSON representation
convert golang structs to typescript interfaces or swagger spec
- Host: GitHub
- URL: https://github.com/zmitry/go2typings
- Owner: zmitry
- License: mit
- Created: 2019-10-28T21:58:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T22:59:32.000Z (almost 5 years ago)
- Last Synced: 2025-03-30T11:24:06.008Z (7 months ago)
- Topics: golang, typescript, typings
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang structs to typescript typings convertor
## Example
[example.main.go](https://github.com/zmitry/go2typings/blob/master/example/main.go)
## How to setup
- create go file with the code bellow
- run this code with `go run````golang
package mainimport (
"github.com/zmitry/go2ts"
// you can use your own
"github.com/zmitry/go2ts/example/types"
)type Root struct {
User types.User
T types.T
}func main() {
s := go2ts.New()
s.Add(types.T{})
s.Add(types.User{})err := s.GenerateFile("./test.ts")
if err != nil {
panic(err)
}
}
```# Custom tags
we support custom tag `ts` it has the following syntax
```
type M struct {
Username string `json:"Username2" ts:"string,optional"`
}
```tsTag type
```
tsTag[0] = "string"|"date"|"-"
tsTag[1] = "optional"|"no-null"|"null"
```see field.go for more info