If gorm is like json marshalling the fields need to be exported, that is 
capitalized. 

Just a thought. 

> On Nov 29, 2018, at 12:02 AM, mmbarighz...@gmail.com wrote:
> 
> New to Go - please bear with me.
> 
> I am trying to create a new row in my table, but the values are being saved 
> as `Null`. Can anyone see the problem here?
> 
> package main
> 
> import (
>     "fmt"
>     "log"
> 
>     "github.com/jinzhu/gorm"
>     _ "github.com/jinzhu/gorm/dialects/postgres"
>     _ "github.com/lib/pq"
> )
> 
> type contact struct {
>     gorm.Model
>     id    int    `gorm:"primary_key;not null;unique;AUTO_INCREMENT"`
>     fname string `gorm:"type:TEXT"`
>     lname string `gorm:"type:TEXT"`
>     email string `gorm:"type:TEXT"`
> }
> 
> func main() {
>     connStr := "user=postgres dbname=postgres sslmode=disable"
>     db, err := gorm.Open("postgres", connStr)
> 
>     if err != nil {
>         log.Fatal(err)
>     }
> 
>     defer db.Close()
> 
>     db.AutoMigrate(&contact{})
> 
>     c := contact{
>         fname: "bob",
>         lname: "job",
>         email: "b...@jb.com",
>     }
> 
>     fmt.Println(&c)
>     db.Create(&c)
> 
> }
> 
> <Screen Shot 2018-11-29 at 1.01.55 AM.png>
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <Screen Shot 2018-11-29 at 1.01.55 AM.png>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to