Go Integration

The Go TypeSchema integration uses the native JSON implementation, this means you don`t need to install any additional package to use the generated DTOs.

DTO

package TypeSchema

// A simple student struct
type Student struct {
    FirstName string `json:"firstName"`
    LastName string `json:"lastName"`
    Age int `json:"age"`
}

Integration

package TypeSchema;

import "os"
import "encoding/json"

func main() {
    input, errRead := os.ReadFile("./input.json")
    if errRead != nil {
        panic(errRead)
    }

    var student Student
    errUnmarshal := json.Unmarshal(input, &student)
    if errUnmarshal != nil {
        panic(errUnmarshal)
    }

    output, errMarshal := json.Marshal(student)
    if errMarshal != nil {
        panic(errMarshal)
    }

    errWrite := os.WriteFile("./output.json", output, 0644)
    if errWrite != nil {
        panic(errWrite)
    }
}