Skip to content

Instantly share code, notes, and snippets.

@Marvin9
Created August 21, 2020 09:18
Show Gist options
  • Save Marvin9/4cafaab9741145e73d4232db05cb4fe6 to your computer and use it in GitHub Desktop.
Save Marvin9/4cafaab9741145e73d4232db05cb4fe6 to your computer and use it in GitHub Desktop.
package database
import (
"github.com/jinzhu/gorm"
)
// Users -
type Users struct {
gorm.Model
Username string
}
// AddUser -
func AddUser(username string) error {
db, err := ConnectDB()
if err != nil {
return err
}
defer db.Close()
db.AutoMigrate(&Users{})
err = db.Create(&Users{
Username: username,
}).Error
if err != nil {
return err
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment