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)arrow-up-right. Verify installation:

go version

Get a Züs Wallet

You’ll need a .json wallet file.

It is typically located at:

~/.zcn/wallet.json

Alternatively, 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 zwalletcliarrow-up-right.

Or you can use any location to create the json file. You can retrieve your wallet info by using recover walletarrow-up-right 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

Create 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

Install Gorilla Mux:

In case you see an error while importing go_zus_handlers, run this command:

4. Build Your Handlers

sdk_handler.go

memfile_handler.go

upload_handler.go

download_handler.go

5. Run Your Server

Expected output:

6. Test With curl

Initialize SDK

Upload a File

Download a File

Last updated