1
0
mirror of https://codeberg.org/crowci/crow.git synced 2025-04-19 15:22:22 +03:00
crow/crow-go
2025-03-10 13:58:57 +01:00
..
2025-03-10 13:58:57 +01:00
2025-01-18 01:27:10 +01:00

crow-go

import (
  "codeberg.org/crowci/crow/v3/crow-go/crow"
  "golang.org/x/oauth2"
)

const (
  token = "dummyToken"
  host  = "http://crow.company.tld"
)

func main() {
  // create an http client with oauth authentication.
  config := new(oauth2.Config)
  authenticator := config.Client(
    oauth2.NoContext,
    &oauth2.Token{
      AccessToken: token,
    },
  )

  // create the crow client with authenticator
  client := crow.NewClient(host, authenticator)

  // gets the current user
  user, err := client.Self()
  fmt.Println(user, err)

  // gets the named repository information
  repo, err := client.RepoLookup("crow-ci/crow")
  fmt.Println(repo, err)
}