-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add go sdk storage examples (#1081)
* chore: add go sdk storage examples * add storage-related keywords to go sdk landing page * update wording Co-authored-by: pgautier404 <[email protected]> --------- Co-authored-by: pgautier404 <[email protected]>
- Loading branch information
1 parent
9e6b94c
commit b102e0c
Showing
5 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
sidebar_position: 3 | ||
sidebar_label: Storage | ||
title: Getting started with Momento Storage in Go | ||
description: Learn the basic building blocks for writing Go code to interact with Momento Storage. | ||
keywords: | ||
- momento | ||
- cache | ||
- caching | ||
- topics | ||
- pubsub | ||
- pub/sub | ||
- eda | ||
- event-driven architecture | ||
- redis | ||
- serverless | ||
- storage | ||
- persistence | ||
- datastore | ||
- database | ||
- durable | ||
- sdk | ||
- sdks | ||
- api | ||
- examples | ||
- resources | ||
- getting started | ||
- quick start | ||
- server-side | ||
- go | ||
- golang | ||
--- | ||
|
||
import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock"; | ||
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet | ||
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl | ||
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl"; | ||
|
||
# Getting Started with Momento Storage in Go | ||
|
||
If you need to get going quickly with Go and Momento Storage, this page contains the basic API calls you'll need. [Check the Go SDK examples](https://github.com/momentohq/client-sdk-go/tree/main/examples) for complete, working examples including build configuration files. | ||
|
||
## Install the Momento SDK | ||
|
||
The Momento SDK is available on Go Packages: [client-sdk-go](https://pkg.go.dev/github.com/momentohq/client-sdk-go). | ||
|
||
:::tip | ||
Visit [Go Packages](https://pkg.go.dev/github.com/momentohq/client-sdk-go) to find the latest available version of the SDK. | ||
::: | ||
|
||
Install the client library in an existing Go project: | ||
|
||
```bash | ||
go get github.com/momentohq/client-sdk-go | ||
``` | ||
|
||
## Set up your API key | ||
|
||
You'll need a Momento API key to authenticate with Momento. You can get one from the [Momento Web Console](https://console.gomomento.com/api-keys). | ||
Once you have your API key, store it in an environment variable so that the Momento client can consume it: | ||
|
||
``` | ||
export MOMENTO_API_KEY=<your Momento API key here> | ||
``` | ||
|
||
## Import libraries and connect to return a StorageClient object | ||
This code sets up the main function, the necessary imports, and the StorageClient that will be used to interact with your store. | ||
|
||
<SdkExampleCodeBlock language={'go'} file={'examples/storage-cheat-sheet/main.go'} /> | ||
|
||
## Create a new store in Momento Storage | ||
Use this function to create a new store in your account. | ||
|
||
<SdkExampleCodeBlock language={'go'} snippetId={'API_Storage_CreateStore'} /> | ||
|
||
|
||
## List the names of existing stores in your account | ||
A simple list of the names of stores for the account. | ||
|
||
<SdkExampleCodeBlock language={'go'} snippetId={'API_Storage_ListStores'} /> | ||
|
||
## Write an item to a store | ||
A simple example of doing a put operation. | ||
|
||
<SdkExampleCodeBlock language={'go'} snippetId={'API_Storage_Put'} /> | ||
|
||
## Read an item from a store | ||
This is an example of a simple read operation to get an item from a store. | ||
|
||
<SdkExampleCodeBlock language={'go'} snippetId={'API_Storage_Get'} /> | ||
|
||
## Running the code | ||
|
||
You can find complete, working examples in the [Go SDK github repo examples directory](https://github.com/momentohq/client-sdk-go/tree/main/examples). | ||
|
||
:::info | ||
Beyond these basic API calls check out the [API reference page](/storage/develop/api-reference/index.mdx) for more information on the full assortment of Momento API calls. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters