Skip to content

Commit 96fb65b

Browse files
committed
add go, js, python
1 parent b43893b commit 96fb65b

30 files changed

+6570
-0
lines changed

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# LBRY Types
2+
3+
Cross-language definitions for standard LBRY types.
4+
5+
## Using LBRY types in your code
6+
7+
### Go
8+
9+
```
10+
package main
11+
12+
import pb "github.com/lbryio/types/go"
13+
import "fmt"
14+
15+
func main() {
16+
title := "Coherence"
17+
metadata := pb.Metadata{Title:&title}
18+
fmt.Printf("Let's watch %s on LBRY!\n", metadata.GetTitle())
19+
}
20+
21+
```
22+
23+
### Python
24+
25+
todo
26+
27+
### Javascript
28+
29+
todo
30+
31+
## Compiling types
32+
33+
You only need to do this if you're modifying the types themselves.
34+
35+
- Download [the protoc binary](https://github.com/google/protobuf/releases) and put it in your path. Make sure you get the one starting with `protoc`, not `protobuf`.
36+
- `./build.sh`
37+
38+
## License
39+
40+
MIT

build.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
#set -x
5+
6+
version_gte() {
7+
[ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]
8+
}
9+
10+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
11+
12+
13+
hash protoc 2>/dev/null || { echo >&2 -e 'error: protoc binary not found\nDownload it from https://github.com/google/protobuf/releases and put it in your path.\nMake sure you get the one starting with `protoc`, not `protobuf`.'; exit 1; }
14+
15+
16+
PROTOC="$(which protoc)"
17+
VERSION="$($PROTOC --version | cut -d' ' -f2)"
18+
MIN_VERSION="3.0"
19+
20+
version_gte "$VERSION" "$MIN_VERSION" || { echo >&2 "error: protoc version must be >= $MIN_VERSION (your $PROTOC is $VERSION)"; exit 1; }
21+
22+
23+
hash protoc-gen-go 2>/dev/null || go get -u github.com/golang/protobuf/protoc-gen-go
24+
hash protoc-gen-go 2>/dev/null || { echo >&2 'error: Make sure $GOPATH/bin is in your $PATH'; exit 1; }
25+
26+
27+
find $DIR/go $DIR/python $DIR/js -type f -delete
28+
29+
30+
protoc --proto_path="$DIR/proto" --python_out="$DIR/python" --go_out="$DIR/go" --js_out="import_style=commonjs,binary:$DIR/js" $DIR/proto/*.proto

go/certificate.pb.go

+174
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)