Based on the answer from @peter-willis, fmt.Sprintf("%.*s", n, s) does not require a hard-coded length.
fmt.Sprintf("%.*s", n, s)