Playground doesn't run my examples

I have added some examples to a project. However, when I look at them at GrB package - - Go Packages I cannot execute them. The playground reports that it doesn’t find the exported identifiers of the package in question.

I have checked everything locally, both with go test and with go build in a clean folder, and there everything works fine.

I am at a loss right now. What am I missing?

Thanks a lot for any hints in advance,

There are also some limitations like
The playground can use most of the standard library, with some exceptions. The only communication a playground program has to the outside world is by writing to standard output and standard error.
In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output.
There are also limits on execution time and on CPU and memory usage.

The only item from this list that might apply is the limit on the execution time, primarily because compiling the library takes somewhat long. Thanks a lot for your reply!

I hope this helps you solve your problem…!

I’m not a Go Playground expert, but I’m assuming it has something to do with your use of cgo:

// #include "GraphBLAS.h"

I couldn’t find anything specifically on “does go support cgo in the playground” or “how to enable cgo in the playground”, but I suspect that is your problem. If, for example, you try to use cgo directly you will get the following result:

package play: build constraints exclude all Go files in /tmp/sandbox4004760245

Go build failed.

You can see in the source that cgo is disabled:

This is conjecture, but, I wonder if there’s an error in the toolchain that’s being swallowed, which is then causing downstream problems. I’m honestly not sure what happens if you build a project with cgo and have CGO_ENABLED=0 (I don’t use cgo personally). Also - check this answer out:

If you run the included playground link it will confirm that your problem is probably not execution time (compiling that playground link takes quite a while!). It might be worth opening an issue in the official go repo to see what they say. I’m assuming they’ll tell you that you’re out of luck with cgo but again, I have no experience with it.


Thanks a lot for the detailed response. I will open an issue and see what they say.

Ok, I didn’t have to submit an issue, because I found this: - they are already aware that playground is lacking when it comes to cgo.

Yeah - that line of code in that changeset is one I linked to above. I was just wondering if they had a workaround or suggestion. That’s from 2021 and it does say:

In the future, we could enable CGO programs to be built and run safely in the gVisor sandbox.

Anyway, sorry it wasn’t a more satisfactory outcome. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.