GO SDK Microservices
This guide provides a complete walkthrough for setting up and running a Go-based microservice that interacts with the Züs decentralized storage network.
1. Prerequisites Setup
Before you begin:
Install Go
install Go (version 1.20+ recommended). Verify installation:
go versionGet a Züs Wallet
You’ll need a .json wallet file.
It is typically located at:
~/.zcn/wallet.jsonAlternatively, you can store the wallet JSON file in any location of your choice. To retrieve your wallet information, you can use the recover wallet command from zwalletcli.
Or you can use any location to create the json file. You can retrieve your wallet info by using recover wallet from the zwalletcli.
Below is sample wallet structure:
{
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"client_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"keys": [
{
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"private_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
],
"mnemonics": "xxxx xxxx xxxx xxxxx",
"version": "1.0",
"date_created": "2023-05-03T12:44:46+05:30",
"nonce": 0
}Create config.json
config.jsonCreate a file named config.json in your project root with the following structure:
2. Project File Structure
Your project should be structured as follows:
3. Code Your main.go
main.goInstall Gorilla Mux:
In case you see an error while importing go_zus_handlers, run this command:
4. Build Your Handlers
sdk_handler.go
sdk_handler.gomemfile_handler.go
memfile_handler.goupload_handler.go
upload_handler.godownload_handler.go
download_handler.go5. Run Your Server
Expected output:
6. Test With curl
curlInitialize SDK
Upload a File
Download a File
Last updated