Use the regexp package to compile a pattern and call MatchString to validate input. This returns a boolean indicating if the string matches the regex.
package main
import (
"fmt"
"regexp"
)
func main() {
pattern := `^[a-zA-Z0-9_]+$`
re := regexp.MustCompile(pattern)
input := "valid_user_123"
if re.MatchString(input) {
fmt.Println("Valid")
} else {
fmt.Println("Invalid")
}
}