Skip to content

Commit 193a9c1

Browse files
committed
feat: Add readme
1 parent aa76852 commit 193a9c1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
11
# golang-enum-to-ts
22
Transform Golang `enum` type to Typescript enum
3+
4+
## Function
5+
6+
### Before (Golang)
7+
```golang
8+
package some
9+
10+
type Status int
11+
12+
const (
13+
Todo Status = iota
14+
Done
15+
Pending
16+
InProgress
17+
)
18+
19+
type Sex string
20+
21+
const (
22+
Female Sex = "female"
23+
Male Sex = "male"
24+
)
25+
26+
func Abctext() {
27+
//dadsad
28+
}
29+
```
30+
31+
### After (Typescript)
32+
33+
```ts
34+
namespace some {
35+
export enum Sex {
36+
Female = 'female',
37+
Male = 'male',
38+
}
39+
export enum Status {
40+
Pending = 2,
41+
InProgress = 3,
42+
Todo = 0,
43+
Done = 1,
44+
}
45+
}
46+
```

0 commit comments

Comments
 (0)