maddyblue / sqlfmt

SQL formatter with width-aware output
https://sqlfum.pt
Apache License 2.0
418 stars 23 forks source link

Any plan to split out the formatting part out to a module? #51

Closed suntong closed 4 years ago

suntong commented 4 years ago

Hi Matt,

Any plan to split out the formatting part out to a module?

maddyblue commented 4 years ago

The formatting logic is already fully contained in the cockroach code which you can call as a normal go package. Note: cockroach isn't go-gettable so would need to use https://github.com/cockroachdb/cockroach-gen with a replace directive in your go.mod. This sqlfmt repo is just the web frontend.

suntong commented 4 years ago

Gotya. thx a lot for the explanation!

CyborgMaster commented 3 years ago

I've been poking around and am having trouble seeing the correct way to do this. Is it possible that we could get a quick example? maybe in the README?

CyborgMaster commented 3 years ago

For example, I'm trying to grab the pertinent parts of main.go and use them with a replace directive

replace github.com/cockroachdb/cockroach => github.com/cockroachdb/cockroach-gen/v20 v20.2.4

but I'm getting the following error:

go: downloading github.com/cockroachdb/cockroach-gen/v20 v20.2.4
stash.teslamotors.com/cas/ion/lineside/cmd/internal/pretty_log imports
    github.com/cockroachdb/cockroach/pkg/sql/parser: go.mod has non-.../v20 module path "github.com/cockroachdb/cockroach" (and .../v20/go.mod does not exist) at revision v20.2.4
stash.teslamotors.com/cas/ion/lineside/cmd/internal/pretty_log imports
    github.com/cockroachdb/cockroach/pkg/sql/sem/builtins: go.mod has non-.../v20 module path "github.com/cockroachdb/cockroach" (and .../v20/go.mod does not exist) at revision v20.2.4
stash.teslamotors.com/cas/ion/lineside/cmd/internal/pretty_log imports
    github.com/cockroachdb/cockroach/pkg/sql/sem/tree: go.mod has non-.../v20 module path "github.com/cockroachdb/cockroach" (and .../v20/go.mod does not exist) at revision v20.2.4