---
title: "Go HTTP Key-Value CRUD | wasmCloud"
description: "This example is a WebAssembly component that demonstrates simple CRUD operations (Create, Read, Update, Destroy) with the wasi:keyvalue/store interface."
canonical: "https://wasmcloud.com/docs/v1/examples/go/component/http-keyvalue-crud/"
---

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 Key-Value CRUD

[This example](https://github.com/wasmCloud/go/tree/main/examples/component/http-keyvalue-crud) is a WebAssembly component that demonstrates simple CRUD operations (Create, Read, Update, Destroy) with the [`wasi:keyvalue/store`](https://github.com/WebAssembly/wasi-keyvalue) interface.

## 📦 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-keyvalue-crud`:

shell

```shell
cd examples/component/http-keyvalue-crud
```

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
- `bindings.wadge.go`: Automatically generated test bindings
- `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 dependencies to run the application locally
- Watch your code for changes and re-deploy when necessary.

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

shell

```shell
wash app list
```

### Send a request

The user provides keys as query strings and values as JSON payloads, with the application performing CRUD operations according to the HTTP method of the request.

To **Create** (or **Update**) a value:

shell

```shell
curl -X POST localhost:8000/crud/key -d '{"foo": "bar", "woo": "hoo"}'
```

text

```text
{"message":"Set key", "value":"{"foo": "bar", "woo": "hoo"}"}
```

To **Read** a value:

shell

```shell
curl localhost:8000/crud/key
```

text

```text
{"message":"Got key", "value":"{"foo": "bar", "woo": "hoo"}"}
```

To **Destroy** a value:

shell

```shell
curl -X DELETE localhost:8000/crud/key
```

text

```text
{"message":"Deleted key"}
```

Read through the comments in `main.go` for step-by-step explanation of how the example works.

### Clean up

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

## 📖 Further reading

When running this example with the `wash dev` command, wasmCloud uses its included NATS key-value store to back key-value operations, but the application could use another store like Redis with no change to the Go code.

You can learn more about capabilities like key-value storage are fulfilled by swappable providers in the [wasmCloud Quickstart](https://wasmcloud.com/docs/v1/tour/hello-world/).

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