---
title: "Go HTTP Client | wasmCloud"
description: "This example is a"
canonical: "https://wasmcloud.com/docs/v1/examples/go/component/http-client/"
---

This is documentation for wasmCloud **v1**, which is no longer actively maintained.

For up-to-date documentation, see the **[latest version](https://wasmcloud.com/docs/)** (v2).

Version: v1

# Go HTTP Client

[This example](https://github.com/wasmCloud/go/tree/main/examples/component/http-client) is a WebAssembly component that calls a random number generator service to get random numbers.

The application...

- Implements a [`wasi:http`](https://github.com/WebAssembly/wasi-http)-compliant HTTP handler
- Uses the [`httpserver` provider](https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-server) to serve requests
- Can be declaratively provisioned in a [wasmCloud](https://wasmcloud.com/docs/v1/intro/) environment

## 📦 Dependencies

> \[!WARNING\] Due to incompatibilities introduced in `wasm-tools` v1.226.0, a version of `wasm-tools` \<= 1.225.0 is **required** for running this example.
>
> You can install `wasm-tools` [v1.225.0 from upstream releases](https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.225.0), or use `cargo` ([Rust toolchain](https://doc.rust-lang.org/cargo/getting-started/installation.html)) -- (i.e. `cargo install --locked wasm-tools@1.225.0`)

Before starting, ensure that you have the following installed in addition to the Go (1.23+) toolchain:

- [`tinygo`](https://tinygo.org/getting-started/install/) for compiling Go (always use the latest version)
- [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools#installation) for Go bindings
- [wasmCloud Shell (`wash`)](https://wasmcloud.com/docs/v1/installation/) for building and running the components and wasmCloud environment

## 👟 Run the example

Clone the [wasmCloud/go repository](https://github.com/wasmcloud/go):

shell

```shell
git clone https://github.com/wasmCloud/go.git
```

Change directory to `examples/component/http-client`:

shell

```shell
cd examples/component/http-client
```

In addition to the standard elements of a Go project, the example directory includes the following files and directories:

- `build/`: Target directory for compiled `.wasm` binaries
- `gen/`: Target directory for Go bindings of [interfaces](https://wasmcloud.com/docs/v1/concepts/interfaces/)
- `wit/`: Directory for WebAssembly Interface Type (WIT) packages that define interfaces
- `wadm.yaml`: Declarative application manifest
- `wasmcloud.lock`: Automatically generated lockfile for WIT packages
- `wasmcloud.toml`: Configuration file for a wasmCloud application

### Start a local development loop

Run `wash dev` to start a local development loop:

shell

```shell
wash dev
```

The `wash dev` command will:

- Start a local wasmCloud environment
- Build this component
- Deploy your application and all requirements to run the application locally, including...
  - Your locally built component
  - The [HTTP server provider](https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-server), which will receive requests from the outside world (on port 8000 by default)
  - The [HTTP client provider](https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-client), which will call a random number generator service
  - Necessary links between providers and your component so your component can handle web traffic
- Watch your code for changes and re-deploy when necessary.

Once the application is deployed, open another terminal tab. To ensure that the application has reached `Deployed` status, you can use `wash app list`:

shell

```shell
wash app list
```

### Send a request

When you send a request, the component will call an upstream API and return a list of random numbers:

shell

```shell
curl localhost:8000
```

text

```text
[438,424,166,260,681]
```

### Clean up

You can stop the `wash dev` process with `Ctrl-C`.

## ⚠️ Issues/FAQ

### `curl` produces a "failed to invoke" error

If `curl`ing produces...

text

```text
failed to invoke `wrpc:http/incoming-handler.handle`: failed to invoke `wrpc:http/incoming-handler@0.1.0.handle`: failed to shutdown synchronous parameter channel: not connected%
```

...the HTTP server may not have finished starting up. You can check that the application has reached `Deployed` status with `wash app list`.

If the issue persists, you may have a lingering HTTP server provider running on your system. You can use `pgrep` to check:

shell

```shell
pgrep -la ghcr_io
```

text

```text
4007604 /tmp/wasmcloudcache/NBCBQOZPJXTJEZDV2VNY32KGEMTLFVP2XJRZJ5FWEJJOXESJXXR2RO46/ghcr_io_wasmcloud_http_server_0_23_1
```

## 📖 Further reading

For more on building components, see the [Component Developer Guide](https://wasmcloud.com/docs/v1/developer/components/) in the wasmCloud documentation.

Last updated on **Nov 20, 2026** by **Victor Adossi**
