3 ms·
You can learn from the Go codebase to get a feel of why this is useful: https://github.com/golang/go/blob/master/src/cmd/go/internal/modfetch/repo.go#L394 http
by mseepgood 2y ago
You can learn from the Go codebase to get a feel of why this is useful:
https://github.com/golang/go/blob/master/src/cmd/go/internal/modfetch/repo.go#L394 https://github.com/golang/go/blob/master/src/cmd/go/internal...
https://github.com/golang/go/blob/master/src/io/fs/fs.go#L262 https://github.com/golang/go/blob/master/src/io/fs/fs.go#L26...
https://github.com/golang/go/blob/master/src/errors/wrap.go#L18 https://github.com/golang/go/blob/master/src/errors/wrap.go#...
https://github.com/golang/go/blob/master/src/go/parser/resolver.go#L49 https://github.com/golang/go/blob/master/src/go/parser/resol...
- metadat 2y agoIf the interface check fails, does the code panic or does the `ok' value just get set to false? If `ok' gets set to false, that seems optimal. Pretty neat, in fact, what other language permits such low-key, easy runtime interface checks?
- 38 2y agothis will panic: v := hello.(world) this never panic: v, ok := hello.(world) and yes, its awesome. people rag on Go because BLARG ERRORS BOILERPLATE, but if you can get over that Go is not Python/JavaScript, you're left with a simple powerful language