1.0 KiB
1.0 KiB
Go-Lemmy
Go bindings to the Lemmy API, automatically generated directly from Lemmy's source code using the generator in cmd/gen.
Example:
ctx := context.Background()
c, err := lemmy.New("https://lemmygrad.ml")
if err != nil {
panic(err)
}
err = c.ClientLogin(ctx, types.Login{
UsernameOrEmail: "user@example.com",
Password: `TestPwd`,
})
if err != nil {
panic(err)
}
_, err = c.SaveUserSettings(ctx, types.SaveUserSettings{
BotAccount: types.NewOptional(true),
})
if err != nil {
panic(err)
}
How to generate
First, build the generator:
go build ./cmd/gen
Clone Lemmy's source code at whatever version you need:
git clone https://github.com/LemmyNet/lemmy -b 0.16.7
Remove all the existing generated code:
rm **/*.gen.go
Execute the generator:
./gen -out-dir .
And that's it! Your generated code should be ready for use.