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
|
|
|
|
2023-09-25 02:28:46 +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
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
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
|
2023-09-25 02:28:46 +00:00
|
|
|
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
|
|
|
```
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
Next, build the generator:
|
2023-01-07 23:15:49 +00:00
|
|
|
|
|
|
|
```bash
|
2023-09-25 02:28:46 +00:00
|
|
|
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
|
2023-09-25 02:28:46 +00:00
|
|
|
./gen -json-file <path_to_docs.json> -out-dir .
|
2023-01-07 23:15:49 +00:00
|
|
|
```
|
|
|
|
|
2023-07-04 00:49:39 +00:00
|
|
|
And that's it! Your generated code should be ready for use.
|