From the course: Go for Developers: Practical Techniques for Effective Coding
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Using file system interfaces - Go Tutorial
From the course: Go for Developers: Practical Techniques for Effective Coding
Using file system interfaces
- In Go 1.16, the Go team wanted to introduce a long-requested feature, the ability to embed files into a Go binary. There had been a variety of third-party tools that did this, but none of them were able to do it without a lot of work. A lot of these tools behaved in the same way. If the file was found in their in-memory store, they would return it. If their store was empty or didn't contain the file, the assumption was the file was in the file system and they would read it from there. The Go team liked this approach as it was very friendly to developers. Using Go Run to start your local web server, for example, would read HTML templates from disc allowing for live updates. But if built with Go Build, the binary would contain all the HTML templates in memory and the developer would have to manually update the binary to see file changes. In order to enable this feature, the Go team had to introduce a new set of interfaces for working with the file system. For this, they introduced the…