Skip to content
/ sinfer Public

⛵ Infer types from structures like JSON and convert into Go source code

License

Notifications You must be signed in to change notification settings

otofune/sinfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sinfer

Infer types from structures like JSON and convert into Go source code

Getting Started

  1. Collect JSON files
cat > a.json <<EOF
{"int": 3, "fl": 1, "optional": "yey"}
EOF
cat > b.json <<EOF
{"int": 0, "fl": 3.2}
EOF
  1. Write configuration file (for detail, see configSchema in index.ts)
cat > config.json <<EOF
{
    "glob": "./{a,b}.json"
}
EOF
  1. Run sinfer
% yarn
% yarn gen ./config.json
yarn run v1.22.10
$ ts-node . ./config.json
struct {
        Integer *(int)  `json:"integer"`
        Float   *(float64)      `json:"float"`
        Optional        string  `json:"optional"`
}
✨  Done in 2.07s.

About

⛵ Infer types from structures like JSON and convert into Go source code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages