Sign inSign up

vovavc/go-to-typescript

By vovavc

•Updated over 3 years ago

Convert golang structs to typescript types

Image
0

1.1K

vovavc/go-to-typescript repository overview

⁠Go to typescript

Convert golang structs to typescript types. Based on typescriptify-golang-structs⁠.

⁠Input variables

NameRequiredDefaultDescription
INPUT_FOLDERtruenoPath to the folder with .go files containing structs
OUTPUT_FILEtruenoPath for typescript file to be generated. For example /src/types will be processed to /src/types.ts
IDENTfalsetabIdentation in generated .ts types file, tab by default
PREFIXfalsenoPrefix for typescript interface, ex.: Prefix_MyApiInterface
SUFFIXfalsenoSuffix for typescript interface, ex.: MyApiInterface_Suffix
CREATE_FROM_METHODfalsenoCreate classes with createFrom method to init an object
CREATE_CONSTRUCTORfalsenoCreate classes with plain construct
DONT_EXPORTfalsenoDon't export created interfaces
CREATE_INTERFACEfalsenoCreate typescript interfaces instead of classes
BACKUP_DIRfalsenoPath to a folder where to store backups

⁠Usage with docker-compose.yml

version: "3.9"
services:
    generate-types:
        image: vovavc/go-to-typescript
        volumes:
            - ./sources:/sources
            - ./src:/src
        environment:
            - INPUT_FOLDER=/sources/path-to-your-golang-structs-folder/
            - OUTPUT_FILE=/src/types
            - CREATE_INTERFACE=true

⁠Contributing

Pull requests are welcome at VoVaVc/go-to-typescript⁠

⁠License

The scripts and documentation in this project are released under the MIT License⁠

Tag summary

Content type

Image

Digest

sha256:25268ee23…

Size

125 MB

Last updated

over 3 years ago

docker pull vovavc/go-to-typescript