Welcome to the new Golem Cloud Docs! 👋
Documentation
Go Language Guide
Setting up the Golem Go SDK

Setting up the Golem Go SDK

⚠️

If the project was created with golem-cli new, it already has the Golem Go SDK set up and these steps can be ignored.

If setting up the Golem Go SDK (opens in a new tab) manually, the following steps are required:

Add the Golem Go SDK as a dependency

Add the following dependency to the project:

$ go get github.com/golemcloud/golem-go

Add all the supported WIT files into the project

The project's wit/deps directory must contain all the WIT files from the golem-wit (opens in a new tab) repository.

Importing WITs into the component's world:

If the project's WIT file was like this:

package golem:demo;
 
world go-example {
  export api;
}

Modify it in the following way:

package golem:demo;
 
world go-example {
  import golem:api/host@0.2.0;
  import golem:rpc/types@0.1.0;
 
  import wasi:blobstore/blobstore;
  import wasi:blobstore/container;
  import wasi:cli/environment@0.2.0;
  import wasi:clocks/wall-clock@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:filesystem/preopens@0.2.0;
  import wasi:filesystem/types@0.2.0;
  import wasi:http/types@0.2.0;
  import wasi:http/outgoing-handler@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/poll@0.2.0;
  import wasi:io/streams@0.2.0;
  // import wasi:keyvalue/eventual-batch@0.1.0; // NOTE: cannot include it because the bindings collide with blobstore
  // import wasi:keyvalue/eventual@0.1.0; // NOTE: cannot include it because the bindings collide with blobstore
  import wasi:logging/logging;
  import wasi:random/random@0.2.0;
  import wasi:random/insecure@0.2.0;
  import wasi:random/insecure-seed@0.2.0;
  import wasi:sockets/ip-name-lookup@0.2.0;
  import wasi:sockets/instance-network@0.2.0;
 
  export api;
}