Go to file
Elara 4ae5f8d387 Add generation instructions to README 2023-01-07 15:15:49 -08:00
cmd/gen Add comments containing source file to generated files 2023-01-07 15:05:40 -08:00
types Add comments containing source file to generated files 2023-01-07 15:05:40 -08:00
.gitignore Use autogenerated bindings for Lemmy 0.16.7 2023-01-05 12:51:45 -08:00
LICENSE Add GPLv3 license 2022-12-10 09:18:40 -08:00
README.md Add generation instructions to README 2023-01-07 15:15:49 -08:00
go.mod Update 'go.mod' 2023-01-06 02:58:39 +00:00
go.sum Use autogenerated bindings for Lemmy 0.16.7 2023-01-05 12:51:45 -08:00
lemmy.go Regenerate code 2023-01-07 14:45:01 -08:00
routes.gen.go Add comments containing source file to generated files 2023-01-07 15:05:40 -08:00
websocket.go Remove debug code 2023-01-05 13:46:07 -08:00

README.md

Go-Lemmy

Go Reference

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.