Skip to content

How to get start? I think it should be very straight forward but I only get panic error. #174

Closed
@AllenDang

Description

@AllenDang

Here is how I start.

  1. go get github.com/kyleconroy/sqlc
  2. cd to sqlc/cmd/sqlc
  3. go build .
  4. copy compiled sqlc to $GOPATH/bin

And then, I'm trying to run the sample.

  1. Mkdir ~/Desktop/sqlctest
  2. Run sqlc init and edit the sqlc.json in project folder.
{
  "version": "1",
  "packages": [
    {
      "name": "db",
      "emit_json_tags": true,
      "emit_prepared_queries": false,
      "path": "internal/db",
      "queries": "./sql/query/",
      "schema": "./sql/schema/"
    }
  ]
}
  1. Create folders in project folder like below.
    截屏2019-12-15下午1 57 46

  2. Edit the author.sql.

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = $1 LIMIT 1;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;
  1. Run sqlc generate ./sql/query/author.sql
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x42b6669]

goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/dinosql.ParseQueries(0xc00017c090, 0x480c471, 0x1, 0xc00011e300, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/allendang/Documents/Gocode/src/github.com/kyleconroy/sqlc/internal/dinosql/parser.go:226 +0x689
github.com/kyleconroy/sqlc/internal/cmd.glob..func4(0x4820620, 0xc000148a60, 0x1, 0x1)
        /Users/allendang/Documents/Gocode/src/github.com/kyleconroy/sqlc/internal/cmd/cmd.go:156 +0x9aa
github.com/spf13/cobra.(*Command).execute(0x4820620, 0xc000148a30, 0x1, 0x1, 0x4820620, 0xc000148a30)
        /Users/allendang/Documents/Gocode/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0xc000160500, 0xc0000bdee8, 0x1, 0x1)
        /Users/allendang/Documents/Gocode/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/allendang/Documents/Gocode/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/kyleconroy/sqlc/internal/cmd.Do(0xc0000200d0, 0x2, 0x2, 0x4530900, 0xc000010010, 0x4530920, 0xc000010018, 0x4530920, 0xc000010020, 0xc0000320b8)
        /Users/allendang/Documents/Gocode/src/github.com/kyleconroy/sqlc/internal/cmd/cmd.go:34 +0x24a
main.main()
        /Users/allendang/Documents/Gocode/src/github.com/kyleconroy/sqlc/cmd/sqlc/main.go:10 +0xad

What went wrong???

And BTW, I think a proper step-by-step getting start guide is really needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions