1

Got this long error when running a simple Go program. Here's my main.go, which has all the functions in a single file (vscode was giving me errors otherwise, even though all files were using package main).

main.go

All it does is call some free data from an api and print it in a Fyne window.

package main

import (
    "C"
    "fmt"
    "io"
    "net/http"
    "time"

    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func Call2(someurl string) (*http.Response, error) {
    req, err := http.NewRequest(http.MethodGet, someurl, nil)
    if err != nil {
        fmt.Printf("Error creating request: %s", err)
        return nil, err
    }
    client := http.Client{
        Timeout: 30 * time.Second,
    }
    res, err := client.Do(req)
    if err != nil {
        fmt.Printf("Error making HTTP request: %s", err)
        return nil, err
    }
    return res, nil
}

func tidyUp() {
    fmt.Println("Exited")
}
func main() {
    myApp := app.New()
    myWindow := myApp.NewWindow("Hello")
    k, err := Call2("https://acre.iex.cloud/v1/data/CORE/REF_DATA?token=pk_79891f5cbcce4099ae063588956f937a")
    if err != nil {
        fmt.Printf("Error making HTTP request: %s", err)
        return
    }
    defer k.Body.Close()
    b, err := io.ReadAll(k.Body)
    if err != nil {
        fmt.Printf("Error reading response body: %s", err)
        return
    }
    //  fmt.Println(string(b))
    myWindow.SetContent(widget.NewLabel(string(b)))
    myWindow.Show()
    myApp.Run()
    tidyUp()
}

Here's the beginning of the (really long) error:

Exception 0xc0000005 0x0 0x7ffbd991a0f0 0x7ff89943445e
PC=0x7ff89943445e
signal arrived during external code execution

runtime.cgocall(0x7ff6ead942c0, 0xc000065da0)
        C:/Program Files/Go/src/runtime/cgocall.go:157 +0x3e fp=0xc000065d78 sp=0xc000065d40 pc=0x7ff6ea9655be
github.com/go-gl/glfw/v3.3/glfw._Cfunc_glfwMakeContextCurrent(0x2157624b2d0)

Here's the end of the error:

        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc01494dfe8 sp=0xc01494dfe0 pc=0x7ff6ea9c8ac1
created by os/signal.Notify.func1.1 in goroutine 55
        C:/Program Files/Go/src/os/signal/signal.go:151 +0x1f
rax     0xfff0fff
rbx     0xd075dff3a0
rcx     0x7ffbd991a0cc
rdi     0x7ff899c26100
rsi     0x2157c392b20
rbp     0xd075dfefb0
rsp     0xd075dfeea8
r8      0xd075dfefc0
r9      0xd075dff3a0
r10     0xd075dff190
r11     0x0
r12     0x100
r13     0x0
r14     0x1
r15     0x0
rip     0x7ff89943445e
rflags  0x10206
cs      0x33
fs      0x53
gs      0x2b
exit status 2
4
  • 1
    exit status 2 means you provided wrong arguments Commented Oct 30, 2023 at 6:58
  • There could be something unexpected about your graphics set up. Are you working locally on a reasonably modern computer? Commented Oct 30, 2023 at 7:29
  • @andy.xyz yes, and I have never messed with my graphics card in any way. Commented Oct 31, 2023 at 11:30
  • Perhaps try opening a bug at GitHub to report this, if it is an issue with the toolkit it should get fixed quickly. Commented Nov 4, 2023 at 9:16

1 Answer 1

0

It looks like it was just a VScode issue. Restarting it worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.