Are you trying to find a pure functional subset of go? In a "pure function", the return value(s) are calculated only from the arguments. The result is not affected by the state of the system, and the state of the system is not affected by the function. That means you can't even do a print() inside a function.
Or are you trying to do some sandboxing of untrusted, user-submitted code, but allowing a larger scope than pure functional behaviour? For example, do you need to allow access the filesystem, or send and receive messages on a channel or queue? If so, does it have to be Go code that is sandboxed? For some applications, an interpreter for a "safe" language may be what you want (e.g. jsonnet <https://github.com/google/go-jsonnet>, cue <https://cuelang.org/>, starlark <https://github.com/bazelbuild/starlark#starlark>). Or you might be able to configure an interpreter for some other language - even an interpreter for Go - to have the restricted behaviour you require. More generally: it's possible to write pure functional code which returns a value which is a "request" to do something. Such requests are then very easy to filter, perform if safe, and then invoke the next function with the result. This is the basic idea behind the IO Monad <https://brian-candler.medium.com/function-programming-illustrated-in-python-part-5-90c4882b21b7> in functional languages. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b672c94a-e8a0-4340-8ece-478ea28ffc0an%40googlegroups.com.