Live data from Hacker News

Gokrazy – A Native Go Userland

gokrazy.org

21–30 of 32 posts

Re: Gokrazy – A Native Go Userland

#21
post #4

gokrazy is a very cool project and something I'd like to see more of. It's not a unikernel per se but it shares the idea of packaging your code and the OS together and shipping it as one. My dream would be a pure Go userspace library to do absolutely anything related to system management you'd need, like managing networking, connecting to Wi-Fi access points, performing upgrades and so on. But it's such a massive und…

I run into this often and share the same desire. I quite like Go, but unfortunately the interaction of "my interests" (such as the userspace library you suggested) and "things Go excels at" isn't very large. Having to do everything important through FFI or shell commands defeats the purpose of writing Go, imo.

You don’t have to. Go can make syscalls directly, and it even lets you drop into assembly directly similar to Rust, etc.

Re: Gokrazy – A Native Go Userland

#23

If you're a fan of this approach to deploying applications and use docker, distroless [1] is a really cool project related to this. It uses debian as the base and supports cgo because it has glibc (and openssl) [1]: https://github.com/GoogleContainerTools/distroless

Relatedly, there's also buildkit[1] and that entire ecosystem. I've been meaning to check out the experience of building containers using Nix, but either way it seems very interesting.

[1]: https://github.com/moby/buildkit

Re: Gokrazy – A Native Go Userland

#24
post #17

I’m too rudimentary of a developer. What’s a Userland? What is this doing that writing apps as Go executables doesn’t or can’t do?

Maybe the easiest way to visualize it is that there is no filesystem at all. No shell, no "libc", no "ssh into the machine", no "cp", "mv" "ls", etc. They do provide a way to get one filesystem in place, but you can only interact with it using golang calls within your application.

"no filesystem" does not fit into this list of things. There is definitely a filesystem. It has an optional sshd, and an optional shell that includes cp, mv, ls, etc, but there is always a filesystem.

Re: Gokrazy – A Native Go Userland

#25

I’m too rudimentary of a developer. What’s a Userland? What is this doing that writing apps as Go executables doesn’t or can’t do?

https://en.wikipedia.org/wiki/User_space#Overview says:

“The term userland (or user space) refers to all code that runs outside the operating system's kernel.”

I see a difference between userland and user space. For userland I would add “and that’s needed to bring the OS to a usable state”. You need code that is triggered when an USB device is plugged in, tools to query what hardware is available, tools to format disks, etc.

“Usable state” is up for discussion, though. For example, I don’t think X11 or Wayland are needed, but opinions on that will vary. That may be why the table in the link I gave has parts shaded yellow.

I don’t think (but Wikipedia disagrees with that by making user space and userland synonymous) anybody calls QT, the Gimp or Open Office part of userland, even though they run in user space.

Re: Gokrazy – A Native Go Userland

#26
FWIW, Caddy would probably work with this, if you need a web server.

Caddy is pure Go, no CGO. We did a bunch of work recently to ensure that none of the dependencies have any CGO code enabled (involved asking upstream dependencies to switch to pure alternatives).

Re: Gokrazy – A Native Go Userland

#27
post #14

I’m too rudimentary of a developer. What’s a Userland? What is this doing that writing apps as Go executables doesn’t or can’t do?

Until someone more experienced than me comments: The userland is the collection of programs and functionality that run outside of the kernel. AFAIK you need some things (but I'm not sure which) apart from the kernel if you want to run your executables, and it looks like Gokrazy provides those.

To clarify a bit, you don’t need additional things to run your executables per se (for example, pure Go binaries can run directly on the Linux kernel) but there are a lot of utilities that you will probably want—things like a process manager, SSH daemon, a shell, etc. These are all userland components.

Re: Gokrazy – A Native Go Userland

#28
post #4

gokrazy is a very cool project and something I'd like to see more of. It's not a unikernel per se but it shares the idea of packaging your code and the OS together and shipping it as one. My dream would be a pure Go userspace library to do absolutely anything related to system management you'd need, like managing networking, connecting to Wi-Fi access points, performing upgrades and so on. But it's such a massive und…

I run into this often and share the same desire. I quite like Go, but unfortunately the interaction of "my interests" (such as the userspace library you suggested) and "things Go excels at" isn't very large. Having to do everything important through FFI or shell commands defeats the purpose of writing Go, imo.

Gokrazy doesn't expect you do to anything through FFI or shell commands, though. The whole idea is you write your entire app in Go. The kernel, the Go runtime, and a little bit of gokrazy utility/glue code (e.g. bringing up the network and doing DHCP) are the entire platform.

Edit to add: it would actually be difficult to do FFI or shell commands within gokrazy since there's no dynamic loader to resolve external symbols when you try to execute a dynamically linked library or program. You'd have to add this feature if you wanted to call out to anything built with a dynamically loaded C runtime (which is damn near everything these days, with one notable exception being Go executables built without CGO).

Re: Gokrazy – A Native Go Userland

#29
post #25

I’m too rudimentary of a developer. What’s a Userland? What is this doing that writing apps as Go executables doesn’t or can’t do?

https://en.wikipedia.org/wiki/User_space#Overview says: “The term userland (or user space) refers to all code that runs outside the operating system's kernel.” I see a difference between userland and user space. For userland I would add “and that’s needed to bring the OS to a usable state”. You need code that is triggered when an USB device is plugged in, tools to query what hardware is available, tools to format dis…

QT, Gimp and Open Office are 100% considered userland. I'd be surprised if you could find very many people who disagree.

Re: Gokrazy – A Native Go Userland

#30

FWIW, Caddy would probably work with this, if you need a web server. Caddy is pure Go, no CGO. We did a bunch of work recently to ensure that none of the dependencies have any CGO code enabled (involved asking upstream dependencies to switch to pure alternatives).

It definitely works with gokrazy, we even have a guide for it: https://gokrazy.org/userguide/install/caddy-http-server/
Post reply on HN