parser icon indicating copy to clipboard operation
parser copied to clipboard

How do you get started?

Open xeoncross opened this issue 5 years ago • 6 comments

The quick start doesn't seem to work because of the dependency on TiDB.

I start by including both packages:

go get github.com/pingcap/parser
go get github.com/pingcap/tidb

This leaves me with a go.mod which looks like this:

...
github.com/pingcap/parser v3.0.12+incompatible
github.com/pingcap/tidb v2.0.11+incompatible // indirect
github.com/pingcap/tipb v0.0.0-20200417094153-7316d94df1ee // indirect 
...

The main issue seems to be that in the version of tidb used, the tidb/types package does not contain parser_driver.

Screen Shot 2020-04-17 at 6 46 41 PM

It looks like it exists in the recent v3.1.0 release.

I tried to force that version but it doesn't seem to be working.

$ go get github.com/pingcap/[email protected]
go get github.com/pingcap/[email protected]: github.com/pingcap/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

How do I get the parser working?

xeoncross avatar Apr 18 '20 00:04 xeoncross

v3.1.0 release is not the latest version and it lacks the package parser_driver.

go get -v github.com/pingcap/[email protected]

should fix the problem.

See https://github.com/pingcap/parser/blob/master/docs/quickstart.md#import-dependencies.

tangenta avatar Jun 29 '20 03:06 tangenta

[~]: cd src/
[~/src]: mkdir colx && cd colx
[~/src/colx]: go mod init colx && touch main.go
go: creating new go.mod: module colx
[~/src/colx]: go get -v github.com/pingcap/[email protected]
go get github.com/pingcap/[email protected]: github.com/pingcap/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4

does not fix...

qiukeren avatar Jul 22 '20 09:07 qiukeren

Okay.

As a workaround, you can specify the githash on v4.0.0-rc.1:

go get -v github.com/pingcap/parser@7329d80

Let's figure out how to solve this annoying problem :(

tangenta avatar Jul 22 '20 10:07 tangenta

I got the same error here by following the quickstart,

C:\Users\zhangysh1995\go\src\eqsql>go get github.com/pingcap/tidb/types/[email protected]
go get github.com/pingcap/tidb/types/[email protected]: github.com/pingcap/[email protected]: invalid ver
sion: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4

The workaround also solved my problem.

zhangysh1995 avatar Sep 02 '20 11:09 zhangysh1995

The workaround also solved my problem.

The quickstart guide is conflicting to itself, we should use go get -v github.com/pingcap/tidb/types/parser_driver@328b6d0 in the Import Dependencies section, but not following the NOTE in Parse SQL text.

zhangysh1995 avatar Sep 02 '20 11:09 zhangysh1995

I can't get this to work after following the quick start guide or the suggestions here.

go get -v github.com/pingcap/parser@7329d80
get "golang.org/x/text": found meta tag vcs.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at //golang.org/x/text?go-get=1
get "go.uber.org/multierr": found meta tag vcs.metaImport{Prefix:"go.uber.org/multierr", VCS:"git", RepoRoot:"https://github.com/uber-go/multierr"} at //go.uber.org/multierr?go-get=1
get "go.uber.org/atomic": found meta tag vcs.metaImport{Prefix:"go.uber.org/atomic", VCS:"git", RepoRoot:"https://github.com/uber-go/atomic"} at //go.uber.org/atomic?go-get=1
get "go.uber.org/zap": found meta tag vcs.metaImport{Prefix:"go.uber.org/zap", VCS:"git", RepoRoot:"https://github.com/uber-go/zap"} at //go.uber.org/zap?go-get=1
get "gopkg.in/natefinch/lumberjack.v2": found meta tag vcs.metaImport{Prefix:"gopkg.in/natefinch/lumberjack.v2", VCS:"git", RepoRoot:"https://gopkg.in/natefinch/lumberjack.v2"} at //gopkg.in/natefinch/lumberjack.v2?go-get=1

go get -v github.com/pingcap/tidb/types/parser_driver@328b6d0
go get: github.com/pingcap/[email protected] updating to
        github.com/pingcap/[email protected] requires
        github.com/pingcap/[email protected] requires
        github.com/pingcap/[email protected] requires
        github.com/pingcap/[email protected] requires
        github.com/pingcap/[email protected] requires
        github.com/pingcap/pd/[email protected]: invalid pseudo-version: revision 428acd53eba2 is not a descendent of preceding tag (v4.0.0-rc.1)

clarkmcc avatar Jul 28 '21 04:07 clarkmcc