soulteary / go-python-ast

Get Python AST with Go.

Home Page:https://soulteary.com/2023/05/22/using-golang-and-docker-to-implement-python-computing-services.html

Repository from Github https://github.comsoulteary/go-python-astRepository from Github https://github.comsoulteary/go-python-ast

Go Python AST

Get Python AST with Go.

Usage

Start Go Python AST service, 8080 for HTTP client and 8081 for GRPC client.

# docker image base debian
docker run --rm -it -p 8080:8080 -p 8081:8081 soulteary/go-python-ast
# or alpine base
docker run --rm -it -p 8080:8080 -p 8081:8081 soulteary/go-python-ast:alpine

You can use the following commands to test the HTTP API.

# curl --request POST 'http://127.0.0.1:8080/api/convert' --header 'Content-Type: application/json' --data-raw 'print("hello world")'

"{\"Module\": {\"body\": [{\"Expr\": {\"value\": {\"Call\": {\"func\": {\"Name\": {\"id\": \"print\", \"ctx\": \"Load\"}}, \"args\": [{\"Str\": {\"s\": \"hello world\"}}], \"keywords\": []}}}}]}}"

You can use the following commands to test the GRPC API.

cd example/grpc-client
go run main.go

Tutorial

Dev

docker build -t soulteary/go-python-ast . -f docker/Dockerfile

Credits

About

Get Python AST with Go.

https://soulteary.com/2023/05/22/using-golang-and-docker-to-implement-python-computing-services.html

License:Apache License 2.0


Languages

Language:Go 73.9%Language:Python 15.1%Language:Dockerfile 11.0%