by debugnik · 1y ago · 0 comments
But why did Go pick the same syntax for cheap conversions and expensive ones, though? I'd expect this to be a standard function, not a type conversion.
dur := time.Second * time.Duration(2)
headers := http.Header(map[string][]string{})
httpDir := http.Dir(filepath.Join(parts...))
In all of these cases, it's just a type-cast which is zero-cost, and I think that's what makes it feel surprising that casting between strings/runes specifically incurs more significant computation than any other cast.