You can do better -- fmt provides a way to give a dynamic width or precision as an int argument.
fmt.Fprintf(os.Stderr, "%*s %s\r", paddingWidth, "", legend)
I'd further wonder whether a separate padding calculation is needed at all (too lazy to go read the source on Github at the moment).