3 ms·
I wonder if Go syntax could be extended to tag statements in addition to struct fields: func decomp(filename string) ([]byte, error) { fd, err := os.
by cabirum 3y ago
I wonder if Go syntax could be extended to tag statements in addition to struct fields:
func decomp(filename string) ([]byte, error) {
fd, err := os.Open(filename) `err`
defer fd.Close()
zd, err := gzip.NewReader(fd) `err`
data, err := io.ReadAll(zd) `errw:"your device could be broken: %w"`
return data, nil
}
Where `err` tag just forwards error if nonnil, and errw is similar to Errorf.