We love the "power of defaults". Each web by default has three predefined groups: Owners, Members and Visitors. But their IDs and names are different from web to web. Luckily there is a helper for getting associated groups.
// .Members() and .Owners() correspondinglygroup, err := sp.Web().AssociatedGroups().Visitors().Get()if err !=nil { log.Fatal(err)}fmt.Printf("Visitors group ID %d, Title \"%s\"\n", group.Data().ID, group.Data().Title,)
In group's .AddUser method the argument should be full and valid login name including security provider membership prefix. For instance, while you can ensure Jane using jane.doe@contoso.onmicrosoft.com the same as an .AddUser method will fail as Jane's login is actually different i:0#.f|membership|jane.doe@contoso.onmicrosoft.com.
If you already know UserID but not sure about LoginName .AddUserByID helper is at the disposal.