https://github.com/go-generalize/go2ts
https://github.com/go-generalize/go2ts
go typescript
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/go-generalize/go2ts
- Owner: go-generalize
- License: mit
- Created: 2020-09-21T07:28:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-05T03:27:43.000Z (over 2 years ago)
- Last Synced: 2024-12-21T21:34:27.709Z (over 1 year ago)
- Topics: go, typescript
- Language: Go
- Homepage:
- Size: 172 KB
- Stars: 23
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go2ts
[](https://pkg.go.dev/github.com/go-generalize/go2ts)
## What is go2ts?
- go2ts is a TypeScript interface generator from Go struct.
- Automatically recognize the Go module in the directory
## Installation
```console
$ go get github.com/go-generalize/go2ts
```
## Usage
```go
// ./example/main.go
package main
import (
"time"
)
type Status string
const (
StatusOK Status = "OK"
StatusFailure Status = "Failure"
)
type Param struct {
Status Status
Version int
Action string
CreatedAt time.Time
}
```
```console
$ go2ts ./example
export type Param = {
Action: string;
CreatedAt: string;
Status: "Failure" | "OK";
Version: number;
}
```
## Known Issues
- [#18](https://github.com/go-generalize/go2ts/issues/18): enums in indirectly parsed packages are not recognized.
## TODO
- Handle MarshalJSON/UnmarshalJSON