occlum/demos/golang
zongmin.gu 942321363d Combine the enclave configuration into the occlum configuration file
Update the occlum.json to align with the gen_enclave_conf design.
Below is the two updated structures:
   "metadata": {
        "product_id": 0,
        "version_number": 0,
        "debuggable": true
    },
    "resource_limits": {
        "max_num_of_threads": 32,
        "kernel_space_heap_size": "32MB",
        "kernel_space_stack_size": "1MB",
        "user_space_size": "256MB"
    }
2020-06-05 11:03:47 +08:00
..
.gitignore Add Golang toolchain and the demo 2020-05-15 03:02:42 +00:00
README.md Polish the Golang demo with Gin web framework 2020-05-29 02:03:41 +00:00
run_golang_on_occlum.sh Combine the enclave configuration into the occlum configuration file 2020-06-05 11:03:47 +08:00
web_server.go Polish the Golang demo with Gin web framework 2020-05-29 02:03:41 +00:00

Use Golang with Occlum

This project demonstrates how Occlum enables Golang programs running in SGX enclaves, the demo program is a HTTP web server based on a widely used web framework(Gin) for Go.

Step 1: Install Gin with occlum-go, it may take a few minutes

occlum-go get -u -v github.com/gin-gonic/gin

Step 2: Build the Golang web server using the Occlum Golang toolchain(i.e., occlum-go)

occlum-go build -o web_server -buildmode=pie ./web_server.go

Step 3: You can run the web server demo on Occlum via

./run_golang_on_occlum.sh

The HTTP web server should now start to listen on port 8090 and serve HTTP requests.

Step 4: To check whether the HTTP server works, run

curl http://127.0.0.1:8090/ping

in another terminal, and get the response {"message":"pong"}.