Skip to content

Commit

Permalink
Add Go Code Snippet Tester (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney authored Nov 1, 2023
1 parent d23233b commit 840e5c9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
ARG VARIANT="18"

# Build stage for Go installation.
#
# The latest versions of Go are not available to
# install with apt-get. Instead, it's simplest to
# install Go with a multi-stage docker build.
FROM golang:1.20 AS golang

FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}

RUN apt-get update
Expand All @@ -13,6 +20,10 @@ RUN apt-get install -y ruby ruby-dev
# Install Java
RUN apt-get install -y default-jdk

# Copy Go from the golang stage.
COPY --from=golang /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"

RUN gem install seamapi
RUN pip install seamapi --break-system-packages

Expand Down
3 changes: 3 additions & 0 deletions snippet-playground/go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Running Go

Just run `go run main.go`
5 changes: 5 additions & 0 deletions snippet-playground/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/seamapi/api-docs/snippet-playground/go

go 1.13

require github.com/seamapi/go v0.1.2
13 changes: 13 additions & 0 deletions snippet-playground/go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/seamapi/go v0.1.2 h1:UbgGeioep6nqUNA0ImvHq3GUdVa98N94ocBy3Ve2nAc=
github.com/seamapi/go v0.1.2/go.mod h1:8CROpjACTmlQW4sZAruZ2Xpqi7L5eczyWL7A4sL9Tns=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
30 changes: 30 additions & 0 deletions snippet-playground/go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"context"
"fmt"
"math/rand"
"os"

seam "github.com/seamapi/go/client"
)

func main() {
if err := run(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}

func run() error {
client := seam.NewClient(
seam.WithBaseURL(fmt.Sprintf("https://%d.fakeseamconnect.seam.vc", rand.Intn(1000000))),
seam.WithApiKey("seam_apikey1_token"),
)
devices, err := client.Devices.List(context.Background(), nil)
if err != nil {
return err
}
fmt.Println(devices)
return nil
}

0 comments on commit 840e5c9

Please sign in to comment.