jschaf / pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.
MIT License
282 stars 26 forks source link

Flag for package name missing #48

Closed goliatone closed 1 year ago

goliatone commented 2 years ago

Is there a way to configure the package in the generated file?

Looking here the mapping from flags to pggen.GenerateOptions it seems we are missing a flag for GoPackage? I was expecting to be able to use a --go-package flag to set a custom package name.

jschaf commented 2 years ago

By default the package name is the same as --output-dir. Is the use-case to set a different package name from the output directory?

jschaf commented 2 years ago

Going to close. Re-open if you need something beyond what --output-dir does.

bweston92 commented 1 year ago

The only issue is when using --output-dir . it generated package . which is invalid, but using pwd instead works.

Context

all: ../../db/schema.sql
    pggen gen go --schema-glob '../../db/schema.sql' --query-glob '../../db/queries/*.sql' -output-dir "$(PWD)"

../../db/schema.sql:
    $(MAKE) -C ../../db/ schema.sql

.PHONY: clean
clean:
    rm *.sql.go

Would of preferred to of done

all: ../../db/schema.sql
    pggen gen go --schema-glob '../../db/schema.sql' --query-glob '../../db/queries/*.sql' -output-dir . --go-package storage
jschaf commented 1 year ago

The only issue is when using --output-dir . it generated package .

Oh, that's a silly bug worth fixing. I'll re-open with an aim of fixing that.