Since May 14th, 2019, it is now possible (from Brad Fitzpatrick)!
The #golang playground now supports third-party imports, pulling them in via https://proxy.golang.org/
Example: https://play.golang.org/p/eqEo7mqdS9l
Multi-file support & few other things up next.
Report bugs atissue 31944, or here on the tweeters.golang/go
(On the "multiple file" support, see, since May. 16th 2019, "Which packages may be imported in the go playground?": see an example here)
netbrain suggests in the comments another example:
On the playground:
package main
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
func main() {
v1 := mat.NewVecDense(4,[]float64{1,2,3,4})
fmt.Println(mat.Dot(v1,v1))
}
woud give '30', using to create a column vector, and mat.NewVecDense() to return the sum of the element-wise product of mat.Dot() and v1v1
The point being: is not part of the Go Standard Library.gonum/mat
Original answers:
The most complete article on Go Playground remains "Inside the Go Playground", which mentions:
godoc/static/static.go (for the default go program displayed in the playground)golang/tools/playground for the sources, with playground/socket/socket.go building and executing the program from the playground editor.None of those processes support importing a remote package (that would be accessed over the internet).
It is very much a self-contained system (that you can run locally as well as using it from play.golang.org), with multiple features stubbed or faked, like the network:Like the file system, the playground's network stack is an in-process fake implemented by the syscall package.
It permits playground projects to use the loopback interface (127.0.0.1).Requests to other hosts will fail.
Update 2017:
You have alternatives:
iafan/goplayspacexiam/go-playgroundBut they still use use the official Go Playground service to build and run Go code, so that would still not allow for external imports.