1 Star 0 Fork 0

成都趣趣网络/typescriptify-golang-structs

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
example.go 1.10 KB
Copy Edit Raw Blame History
cobra authored 2021-09-06 18:47 +08:00 . mod
package main
import "gitee.com/cdququ/typescriptify-golang-structs/typescriptify"
type Address struct {
// Used in html
City string `json:"city"`
Number float64 `json:"number"`
Country string `json:"country,omitempty"`
}
type PersonalInfo struct {
Hobbies []string `json:"hobby"`
PetName string `json:"pet_name"`
}
type Person struct {
Name string `json:"name"`
PersonalInfo PersonalInfo `json:"personal_info"`
Nicknames []string `json:"nicknames"`
Addresses []Address `json:"addresses"`
Address *Address `json:"address"`
Metadata []byte `json:"metadata" ts_type:"{[key:string]:string}"`
Friends []*Person `json:"friends"`
}
func main() {
converter := typescriptify.New()
converter.CreateConstructor = true
converter.Indent = " "
converter.BackupDir = ""
converter.Add(Person{})
err := converter.ConvertToFile("browser_test/example_output.ts")
if err != nil {
panic(err.Error())
}
converter.CreateInterface = true
err = converter.ConvertToFile("browser_test/example_output_interfaces.ts")
if err != nil {
panic(err.Error())
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/cdququ/typescriptify-golang-structs.git
git@gitee.com:cdququ/typescriptify-golang-structs.git
cdququ
typescriptify-golang-structs
typescriptify-golang-structs
v0.2.6

Search