C
Coder.com9mo ago
Chris

Using the golang codersdk

I'd like to use the codersdk to write a simple program for updating my templates. However, when I try to import github.com/coder/coder/codersdk, I get the following error when building my program:
github.com/coder/coder/codersdk imports
github.com/coder/coder/tailnet imports
tailscale.com/wgengine/monitor: module tailscale.com@latest found (v1.60.1), but does not contain package tailscale.com/wgengine/monitor
github.com/coder/coder/codersdk imports
github.com/coder/coder/tailnet imports
tailscale.com/wgengine/monitor: module tailscale.com@latest found (v1.60.1), but does not contain package tailscale.com/wgengine/monitor
Does anyone know how to solve this? Thanks!
2 Replies
Codercord
Codercord9mo ago
<#1217318577007366144>
Category
Bug report
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Chris
ChrisOP9mo ago
I figured this out. I was importing "github.com/coder/coder/codersdk" instead of "github.com/coder/coder/v2/codersdk" I'm now running into the following issue trying to build a simple program to communicate with the Coder API. Here is my program:
package main

import (
"fmt"
"net/url"

"github.com/coder/coder/v2/codersdk"
)

const coderHost = "http://devspaces.us-west-1.elasticbeanstalk.com"

func main() {
client := codersdk.New(&url.URL{Scheme: "https", Host: coderHost})
res, err := client.BuildInfo()
if err != nil {
fmt.Println("Error: ", err)
return
}
fmt.Println("Response: ", res)
}
package main

import (
"fmt"
"net/url"

"github.com/coder/coder/v2/codersdk"
)

const coderHost = "http://devspaces.us-west-1.elasticbeanstalk.com"

func main() {
client := codersdk.New(&url.URL{Scheme: "https", Host: coderHost})
res, err := client.BuildInfo()
if err != nil {
fmt.Println("Error: ", err)
return
}
fmt.Println("Response: ", res)
}
When I try to build this program, I get the following error:
# gvisor.dev/gvisor/pkg/sync
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/gate_unsafe.go:114:3: undefined: goready
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/gate_unsafe.go:144:2: undefined: gopark
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:76:3: undefined: semacquire
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:102:4: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:152:3: undefined: semacquire
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:179:3: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:207:3: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/seqcount.go:87:6: undefined: canSpin
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/seqcount.go:89:4: undefined: doSpin
# tailscale.com/net/tsaddr
../go/pkg/mod/[email protected]/net/tsaddr/tsaddr.go:255:21: type func(ri netip.Prefix, rj netip.Prefix) bool of func(ri, rj netip.Prefix) bool {…} does not match inferred type func(a netip.Prefix, b netip.Prefix) int for func(a E, b E) int
# gvisor.dev/gvisor/pkg/sync
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/gate_unsafe.go:114:3: undefined: goready
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/gate_unsafe.go:144:2: undefined: gopark
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:76:3: undefined: semacquire
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:102:4: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:152:3: undefined: semacquire
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:179:3: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/rwmutex_unsafe.go:207:3: undefined: semrelease
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/seqcount.go:87:6: undefined: canSpin
../go/pkg/mod/gvisor.dev/[email protected]/pkg/sync/seqcount.go:89:4: undefined: doSpin
# tailscale.com/net/tsaddr
../go/pkg/mod/[email protected]/net/tsaddr/tsaddr.go:255:21: type func(ri netip.Prefix, rj netip.Prefix) bool of func(ri, rj netip.Prefix) bool {…} does not match inferred type func(a netip.Prefix, b netip.Prefix) int for func(a E, b E) int
Want results from more Discord servers?
Add your server