A Golang client for Visual Studios Team Services
Go get it:
$ go get github.com/samkreter/vsts-goclient
Either import to package up client:
import vstsClient "github.com/samkreter/vsts-goclient/client"
or import the specific api:
import vstsgit "github.com/samkreter/vsts-goclient/api/git"
-
To authenticate, Get a VSTS personal access token. This can be generated on your account page under the security tab.
-
Create an auth context using your username and the personal access token as the password:
auth := context.WithValue(context.Background(), vstsgit.ContextBasicAuth, vstsgit.BasicAuth{ UserName: "username", Password: "personalAccessToken", })
-
Create a client and change the basepath to your vsts account:
cfg := vsts.NewConfiguration() client := vsts.NewAPIClient(cfg) client.ChangeBasePath("https://youraccount.visualstudio.com")
-
Use the auth to make calls using the client
prs, _, err := client.PullRequestsApi.GetPullRequests(auth, "repositoryName", "ProjectName", "4.0", nil) if err != nil { log.Fatal(err) } fmt.Println(prs)
Please feel free to contribute! Bug fixes are more than welcome any time. If you'd like to change an existing implementation or see a new feature, open an issue first so we can discuss it.