Answer the question
In order to leave comments, you need to log in
Why do assignment errors occur when creating a type in Golang?
Greetings.
When trying to build the application, the following errors occur:
# command-line-arguments
./main.go:10: implicit assignment of unexported field 'login' in user.User literal
./main.go:11: implicit assignment of unexported field 'password' in user.User literal
main.go
package main
import (
"fmt"
"packageTest/user"
)
func main() {
var bob = user.User {
"Bob",
"superbob",
}
fmt.Println(bob.GetLogin())
}
user/user.go
package user
type User struct {
login string
password string
}
func (User *User) GetLogin() string {
return User.login
}
type User struct {
Login string
Password string
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question