Re:Thirteen Years of Go
by TrustPatches on Friday November 11, 2022 @01:50PM
(#33564995)
Not sure if it’s an exact parallel, but you can also embed files into rust binaries with “include_bytes!” and “include_str!”.
Re:Thirteen Years of Go
by 5e92cb50239222b on Friday November 11, 2022 @02:24PM
(#33565485)
It's a bit more advanced than what Rust macros provided last time I checked. You can shove whole directories in there and then traverse them or serve as static resources with pretty much one line of code.
Random blog post with a few examples:
https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
Re:Thirteen Years of Go
by TrustPatches on Friday November 11, 2022 @03:44PM
(#33566547)
Very cool, I guess one the the advantages of rust macros is that you could write your own to do something more advanced in theory
Re:Thirteen Years of Go
by super_flanker on Friday November 11, 2022 @03:53PM
(#33566666)
You can do the same in Rust with include_dir[1]
I've gone as far as embedding a ReactJS app inside of Go's embedFS. It's pretty damn powerful.
You can avoid Arc in rust the same way you avoid mutexes in go - use channels instead. I find programming rust with channels between tasks feels quite ergonomic. Also, at least to me, it seems like it's a no brainier to pick a language with a GC if your target runtime environment allows for it.
I also love 'import "embed"' in Go to embed web files (templates) inside a binary and then deploy/manage that one binary with systemd with zero downtime updates with systemd port activation. Slick.