Skip to content

rohanshiva/deta-go

This branch is 4 commits ahead of, 55 commits behind deta/deta-go:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

756c876 · Jul 1, 2021

History

52 Commits
Apr 8, 2021
Apr 6, 2021
Nov 6, 2020
Nov 6, 2020
Nov 6, 2020
Apr 8, 2021
Nov 6, 2020
Jul 1, 2021
Jun 25, 2021
Jul 1, 2021
Jul 1, 2021
Apr 6, 2021

Repository files navigation

DETA SDK for Go

Go Doc

deta-go is the official Deta SDK for Go.

Installing

Use go get to retreive the SDK to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/deta/deta-go

To update the SDK use go get -u to retrieve the latest version of the SDK.

go get -u github.com/deta/deta-go

If you are using Go modules, your go get will default to the latest tagged release version of the SDK. To get a specific release version of the SDK use @<tag> in your go get command.

go get github.com/deta/deta-go@v0.0.1

To get the latest SDK repository change use @latest.

go get github.com/aws/deta-go@latest

Example

package main

import (
	"fmt"
	"github.com/deta/deta-go"
)

type User struct {
	Key string `json:"key"` // json struct tag key to denote the key
	Username string `json:"username"`
	Email string `json:"email"`
}

func main(){
	d, err := deta.New("project_key")
	if err != nil{
		fmt.Println("failed to init a new Deta instance:", err)
		return
	}

	db, err := d.NewBase("base_name")
	if err != nil{
		fmt.Println("failed to init a new Base instance:", err)
		return
	}

	u := &User{
		Key: "abasd",
		Username: "jimmy",
		Email: "jimmy@deta.sh",
	}
	key, err := db.Put(u)
	if err != nil {
		fmt.Println("failed to put item:", err)
		return
	}
	fmt.Println("successfully put item with key", key)
}

More examples and complete documentation on https://docs.deta.sh/docs/base/sdk

Packages

No packages published

Languages

  • Go 100.0%