| ▲ | tialaramex 8 hours ago | |
It's been many years since I wrote any Go for a living, but does Go seriously lack a way to say "foo is probably 32 bytes, give me the 32 byte array, and if I'm wrong about how big foo is, let me handle that" ? If the caller was expected to provide a duration and your language has a duration type, you presumably wouldn't take a string, parse that and if it isn't a duration return some not-a-duration error, you'd just make the parameter a duration. It seems like this ought to be a similar situation. | ||
| ▲ | 0x696C6961 an hour ago | parent | next [-] | |
How did you write Go for a living and simultaneously not know anything about the language? | ||
| ▲ | des429 35 minutes ago | parent | prev | next [-] | |
Who are u expecting an answer from? | ||
| ▲ | 7 hours ago | parent | prev | next [-] | |
| [deleted] | ||
| ▲ | throwaway894345 7 hours ago | parent | prev [-] | |
> It's been many years since I wrote any Go for a living, but does Go seriously lack a way to say "foo is probably 32 bytes, give me the 32 byte array, and if I'm wrong about how big foo is, let me handle that" ? Not in the static type signature, but you can do that as a runtime check either by casting and handling the potential panic (as described above) or by checking the size and returning an error if it's not as expected, which is what the library does. | ||