Go Setup
Fory Go provides xlang and native Object Serialization, generated models, and
Fory gRPC. It is published as github.com/apache/fory/go/fory and requires Go
1.25 or later.
Verify the Toolchain
go version
go env GOPROXY
Object Serialization
Create a module and install the released Fory module:
mkdir fory-example
cd fory-example
go mod init example.com/fory-example
go get github.com/apache/fory/go/fory@v1.5.0
If a Go proxy has not picked up a new submodule tag yet, retry later or use
GOPROXY=direct temporarily.
main.go
package main
import (
"fmt"
"github.com/apache/fory/go/fory"
)
type User struct {
ID int64
Name string
}
func main() {
f := fory.New(fory.WithXlang(true))
if err := f.RegisterStruct(User{}, 1); err != nil {
panic(err)
}
bytes, err := f.Serialize(&User{ID: 1, Name: "Alice"})
if err != nil {
panic(err)
}
var decoded User
if err := f.Deserialize(bytes, &decoded); err != nil {
panic(err)
}
fmt.Println(decoded.Name)
}
go run .
Use xlang mode for cross-language data and native mode for Go-only data. Continue with Go Object Serialization, configuration, and schema evolution.
Other Capabilities
- Fory IDL and Compiler generates Go models and registration helpers. See Compiler Getting Started and the Go generated-code guide.
- Fory gRPC uses grpc-go transports with Fory-encoded messages. See Go gRPC.