3 ms·
Go enforces the convention of using the architecture name as the last part of the filename as a way to compile code specific to that platform. For example, code
by sudhirj 9y ago
Go enforces the convention of using the architecture name as the last part of the filename as a way to compile code specific to that platform. For example, code that used epoll would be in _linux.go, and the windows and mac versions would be named appropriately.
- deleted 9y ago[deleted]
- cesarb 9y agoThat sounds fragile. Does that mean that, whenever golang is ported to a new platform, code which happened to have the same filename suffix as that new platform's short name will stop working everywhere else?
- randomdata 9y agoIdiomatically, underscores are reserved for files that are given special treatment, like architecture-specific code or test files. It is not strictly enforced by the compiler, so theoretically you could cause this scenario, but if you write Go the Go way, it will not be an issue.
- encoderer 9y agoGolang wouldn’t be “ported” to a new platform like, say, python. You would need to re-compile for that platform, and address any platform specific code at that point.