Skip to content

sanity-io/client-go

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
api
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Sanity client in Go

Under development! For developers with an adventurous spirit only.

This is a client for Sanity written in Go.

Using

See the API reference for the full documentation.

package main

import (
  "log"
  "context"

  sanity "github.com/sanity-io/client-go"
)

func main() {
  client, err := sanity.New("zx3vzmn!",
    sanity.WithCallbacks(sanity.Callbacks{
      OnQueryResult: func(result *sanity.QueryResult) {
        log.Printf("Sanity queried in %d ms!", result.Ms)
      },
    }),
    sanity.WithToken("mytoken"),
    sanity.WithDataset("production"))
  if err != nil {
    log.Fatal(err)
  }

  var project struct {
    ID    string `json:"_id"`
    Title string
  }
  if err = client.Query(context.Background(), "*[_type == 'project' && _id == $id][0]", &project,
    sanity.Param("id", "123")); err != nil {
    log.Fatal(err)
  }

  log.Printf("Project: %+v", project)
}

Installation

go get github.com/sanity-io/client-go

Requirements

Go 1.13 or later.

License

See LICENSE file.

About

Sanity client for Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages