This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check previous releases.
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs
To install using go get
:
go get github.com/appwrite/sdk-for-go
-
clone this repo.
-
create a project and within this project a collection.
-
configure the documents in the collection to have a key = hello.
-
Then inject these environment variables:
export YOUR_ENDPOINT=https://appwrite.io/v1 export YOUR_PROJECT_ID=6…8 export YOUR_KEY="7055781…cd95" export COLLECTION_ID=616a095b20180
Create main.go
file with:
package main
import (
"log"
"os"
"time"
"github.com/appwrite/sdk-for-go/appwrite"
"github.com/appwrite/sdk-for-go/id"
)
func main() {
client := appwrite.NewClient(
appwrite.WithEndpoint(os.Getenv("YOUR_ENDPOINT")),
appwrite.WithProject(os.Getenv("YOUR_PROJECT_ID")),
appwrite.WithKey(os.Getenv("YOUR_KEY")),
)
databases := appwrite.NewDatabase(client)
data := map[string]string{
"hello": "world",
}
doc, err := databases.CreateDocument(
os.Getenv("DATABASE_ID"),
os.Getenv("COLLECTION_ID"),
id.Unique(),
data,
)
if err != nil {
log.Printf("Error creating document: %v", err)
}
log.Printf("Created document: %v", doc)
}
-
After that, run the following
% go run main.go
2021/10/16 03:41:17 Created document: map[$collection:616a095b20180 $id:616a2dbd4df16 $permissions:map[read:[] write:[]] hello:world]
This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.
Please see the BSD-3-Clause license file for more information.