You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Short answer: yes.
See detailed explanation below.
By default go-playground used for short snippets of the code that placed in a single file with default name snippet.go. But design of go-playground allows to extend it for an abitrary number of files and packages. Especially it is convenient when you use go modules.
The go-playground creates a new directory for a new snippet. For example I just added the new snippet and got:
/home/a/go/src/playground/at-2022-01-06-192907:
total 12
drwxr-xr-x 1 a a 48 jan 6 19:31 .
drwxr-xr-x 1 a a 4730 jan 6 19:29 ..
-rw-r--r-- 1 a a 48 jan 6 19:29 go.mod
-rw-r--r-- 1 a a 357 jan 6 19:29 snippet.go
You could add another files (with find-file) to the same main package. As well as directories with a new packages (with mkdir for example). Here I added "sample" package to the subdirectory:
Import path looks a bit weird by default. You would change the module name in go.mod. For example I changed it from "playground/at-2022-01-06-192907" to "play":
module play
go 1.17
Then I could import "sample" with shorter new path:
Just treat go-playground as a fully functional go project that created with a temporary path. You could clean old snippet directories or keep them for history (removing of old snippets out of scope of go-playground yet). But anyway the created snippets is general Go projects that could set own subpackages or import any external packages.
Go playground has a multi-file support, like https://play.golang.org/p/rq4J90MxTKJ
Is there any way to execute similar snippet in go-playground?
The text was updated successfully, but these errors were encountered: