go-lemmy/README.md

44 lines
922 B
Markdown
Raw Permalink Normal View History

2022-12-10 17:17:16 +00:00
# Go-Lemmy
2023-07-04 01:24:34 +00:00
[![Go Reference](https://pkg.go.dev/badge/go.arsenm.dev/go-lemmy.svg)](https://pkg.go.dev/go.elara.ws/go-lemmy)
2022-12-10 17:52:09 +00:00
Go bindings to the [Lemmy](https://join-lemmy.org) API, automatically generated from Lemmy's source code using the generator in [cmd/gen](cmd/gen).
2022-12-10 17:17:16 +00:00
2023-10-09 19:51:41 +00:00
### Examples
2023-01-08 08:47:32 +00:00
2023-10-09 19:51:41 +00:00
Examples can be found in the [examples](examples) directory.
2023-01-07 23:15:49 +00:00
### How to generate
First, clone the [lemmy-js-client](https://github.com/LemmyNet/lemmy-js-client) repo at whatever version you need:
2023-01-07 23:15:49 +00:00
```bash
git clone https://github.com/LemmyNet/lemmy-js-client -b 0.18.3
```
Inside it, build the JSON docs file:
```bash
npm run docs -- --json docs.json
2023-01-07 23:15:49 +00:00
```
Next, build the generator:
2023-01-07 23:15:49 +00:00
```bash
go build ./cmd/gen
2023-01-07 23:15:49 +00:00
```
Remove all the existing generated code:
```bash
rm **/*.gen.go
```
Execute the generator:
```bash
./gen -json-file <path_to_docs.json> -out-dir .
2023-01-07 23:15:49 +00:00
```
And that's it! Your generated code should be ready for use.