Skip to content

Instantly share code, notes, and snippets.

@mtsmfm
Created October 11, 2020 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtsmfm/738f16a88a0104d4f40692d68f30d68e to your computer and use it in GitHub Desktop.
Save mtsmfm/738f16a88a0104d4f40692d68f30d68e to your computer and use it in GitHub Desktop.
$ DATABASE_URL=postgres://postgres:password@postgres/postgres?sslmode=disable go run utils/foo.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x68e9dc]
goroutine 1 [running]:
github.com/ericlagergren/decimal.(*Big).IsNaN(...)
/home/app/go/pkg/mod/github.com/ericlagergren/decimal@v0.0.0-20181231230500-73749d4874d5/big.go:853
github.com/volatiletech/sqlboiler/v4/types.decimalValue(0x0, 0x8fe300, 0x0, 0x0, 0x7fa1a03ebca0, 0x8a9601)
/home/app/go/pkg/mod/github.com/volatiletech/sqlboiler/v4@v4.2.0/types/decimal.go:140 +0x3c
github.com/volatiletech/sqlboiler/v4/types.Decimal.Value(0x0, 0xc0001a15f0, 0x40d1e5, 0x6c4760, 0x7007c0)
/home/app/go/pkg/mod/github.com/volatiletech/sqlboiler/v4@v4.2.0/types/decimal.go:58 +0x30
database/sql/driver.callValuerValue(0x7fa1a03ebca0, 0x0, 0x0, 0x7fa1a03ebca0, 0x0, 0x7fa1a03ebc01)
/usr/local/go/src/database/sql/driver/types.go:233 +0xc5
database/sql/driver.defaultConverter.ConvertValue(0x7007c0, 0x0, 0x6b1720, 0x8b26c0, 0x0, 0x0)
/usr/local/go/src/database/sql/driver/types.go:243 +0x79d
database/sql.defaultCheckNamedValue(0xc0001010b8, 0x0, 0x0)
/usr/local/go/src/database/sql/convert.go:97 +0x38
database/sql.driverArgsConnLocked(0x765440, 0xc0001ae000, 0x0, 0xc00000ec80, 0x2, 0x2, 0x34, 0x6fcea0, 0x40c10c, 0x8cb4a0, ...)
/usr/local/go/src/database/sql/convert.go:177 +0x193
database/sql.(*DB).execDC.func2()
/usr/local/go/src/database/sql/sql.go:1566 +0xee
database/sql.withLock(0x763b60, 0xc00015c6c0, 0xc0001a1aa8)
/usr/local/go/src/database/sql/sql.go:3284 +0x69
database/sql.(*DB).execDC(0xc00010dba0, 0x765dc0, 0xc0000160b0, 0xc00015c6c0, 0xc0001a1bd0, 0xc0000208c0, 0x33, 0xc00000ec80, 0x2, 0x2, ...)
/usr/local/go/src/database/sql/sql.go:1565 +0x495
database/sql.(*DB).exec(0xc00010dba0, 0x765dc0, 0xc0000160b0, 0xc0000208c0, 0x33, 0xc00000ec80, 0x2, 0x2, 0x700701, 0xc00000ec28, ...)
/usr/local/go/src/database/sql/sql.go:1550 +0x139
database/sql.(*DB).ExecContext(0xc00010dba0, 0x765dc0, 0xc0000160b0, 0xc0000208c0, 0x33, 0xc00000ec80, 0x2, 0x2, 0x2, 0x0, ...)
/usr/local/go/src/database/sql/sql.go:1528 +0xe5
github.com/mtsmfm/stunning-waffle/models.(*User).Insert(0xc00000ec20, 0x765dc0, 0xc0000160b0, 0x766a80, 0xc00010dba0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/app/server/models/users.go:489 +0x6b0
main.main()
/app/server/utils/foo.go:18 +0xc5
exit status 2
package main
import (
"context"
"database/sql"
"os"
_ "github.com/lib/pq"
"github.com/mtsmfm/test/models"
"github.com/volatiletech/sqlboiler/v4/boil"
)
func main() {
ctx := context.Background()
db, _ := sql.Open("postgres", os.Getenv("DATABASE_URL"))
user := models.User{}
user.Insert(ctx, db, boil.Infer())
}
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
dollars NUMERIC NOT NULL
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment