func (u *User) Create(password string) {
	if !u.Exists() {
		hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
		if err != nil {
			log.Fatalf("Couldn't generate hashed password: %v", err)
		}
		u.Password = string(hash)

		stmt := `INSERT INTO users(name, password) VALUES (?, ?)`
		db.Exec(stmt, u.Name, u.Password)
	}
}
// Create inserts this new user into the database.
// The user receiver should only convey the name of this new user.
Create inserts this new user into the database.
The user receiver should only convey the name of this new user.
// Create inserts this new user into the database . // The user receiver should only convey the name of this new user .
func (u *User) Create(password string) {
	if !u.Exists() {
		hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
		if err != nil {
			log.Fatalf("Couldn't generate hashed password: %v", err)
		}
		u.Password = string(hash)
		stmt := `INSERT INTO users(name, password) VALUES (?, ?)`
		db.Exec(stmt, u.Name, u.Password)
	}
}
func ( u * User ) Create ( password string ) { if ! u . Exists ( ) { hash , err := bcrypt . GenerateFromPassword ( [ ] byte ( password ) , bcrypt . DefaultCost ) if err != nil { log . Fatalf ( " " , err ) } u . Password = string ( hash ) stmt := `INSERT INTO users(name, password) VALUES (?, ?)` db . Exec ( stmt , u . Name , u . Password ) } }
Create inserts this new user into the database.
Create inserts this new user into the database .