Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: runtime error: index out of range #43

Closed
k1LoW opened this issue Jul 25, 2018 · 9 comments
Closed

panic: runtime error: index out of range #43

k1LoW opened this issue Jul 25, 2018 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@k1LoW
Copy link
Owner

k1LoW commented Jul 25, 2018

link #36 (comment)

# cat /etc/redhat-release 
CentOS release 6.9 (Final)
# mysql --version
mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper
# go version
go version go1.9.6 linux/amd64
# go get -u github.com/k1LoW/tbls
# DEBUG=1 tbls doc mysql://user:password@localhost:3306/tbls_mysql57 ./dbdoc
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/k1LoW/tbls/db.Analyze(0x7ffdb65f48b3, 0x46, 0x0, 0x0, 0x0)
        /root/go/src/github.com/k1LoW/tbls/db/db.go:28 +0x453
github.com/k1LoW/tbls/cmd.glob..func4(0xaa7620, 0xc420118e40, 0x2, 0x2)
        /root/go/src/github.com/k1LoW/tbls/cmd/doc.go:56 +0x65
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).execute(0xaa7620, 0xc420118e00, 0x2, 0x2, 0xaa7620, 0xc420118e00)
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xaa7ae0, 0xc42001c0b8, 0x0, 0xc42004ff48)
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:852 +0x334
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).Execute(0xaa7ae0, 0x0, 0x0)
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/k1LoW/tbls/cmd.Execute()
        /root/go/src/github.com/k1LoW/tbls/cmd/root.go:53 +0x2d
main.main()
        /root/go/src/github.com/k1LoW/tbls/main.go:34 +0x20
@k1LoW k1LoW added the bug Something isn't working label Jul 25, 2018
@k1LoW k1LoW self-assigned this Jul 25, 2018
@k1LoW
Copy link
Owner Author

k1LoW commented Jul 25, 2018

@ymaeyama

該当箇所のエラー詳細を出せるようにしました。もう一度 go get -u 後に試してもらっても良いですか? 🙏

@ymaeyama
Copy link

@k1LoW

# go get -u github.com/k1LoW/tbls
# tbls version
0.10.1
# DEBUG=1 tbls doc mysql://user:password@localhost:3306/tbls_mysql57 ./dbdoc
Error: invalid DSN mysql://user:password@localhost:3306/tbls_mysql57
github.com/k1LoW/tbls/db.Analyze
        /root/go/src/github.com/k1LoW/tbls/db/db.go:29
github.com/k1LoW/tbls/cmd.glob..func4
        /root/go/src/github.com/k1LoW/tbls/cmd/doc.go:56
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).execute
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:766
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:852
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).Execute
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:800
github.com/k1LoW/tbls/cmd.Execute
        /root/go/src/github.com/k1LoW/tbls/cmd/root.go:53
main.main
        /root/go/src/github.com/k1LoW/tbls/main.go:34
runtime.main
        /usr/lib/golang/src/runtime/proc.go:195
runtime.goexit
        /usr/lib/golang/src/runtime/asm_amd64.s:2337

@k1LoW
Copy link
Owner Author

k1LoW commented Jul 25, 2018

Error: invalid DSN mysql://user:password@localhost:3306/tbls_mysql57 を見る限りinvalidなDSNではない気がしますね。。。

@ymaeyama 再度エラーの充実化をしましたので go get -u 後に試してもらっても良いですか?

@ymaeyama
Copy link

@k1LoW
ローカルの捨てDBなので、実際のパスワードのログを出しますね。
MySQLのバージョンではなく、パスワード内で使われる文字列が問題のようです。

# DEBUG=1 tbls doc mysql://centos69_db_user1:QvAw1VhMVMORLhr#@localhost:3306/tbls_mysql57 ./dbdoc
Error: invalid DSN. parse mysql://centos69_db_user1:QvAw1VhMVMORLhr#@localhost:3306/tbls_mysql57 -> &dburl.URL{URL:url.URL{Scheme:"mysql", Opaque:"", User:(*url.Userinfo)(nil), Host:"centos69_db_user1:QvAw1VhMVMORLhr", Path:"", RawPath:"", ForceQuery:false, RawQuery:"", Fragment:"@localhost:3306/tbls_mysql57"}, OriginalScheme:"mysql", Proto:"tcp", Driver:"mysql", Unaliased:"mysql", DSN:"tcp(centos69_db_user1:QvAw1VhMVMORLhr)/", hostPortDB:[]string{"centos69_db_user1", "QvAw1VhMVMORLhr", ""}}
github.com/k1LoW/tbls/db.Analyze
        /root/go/src/github.com/k1LoW/tbls/db/db.go:29
github.com/k1LoW/tbls/cmd.glob..func4
        /root/go/src/github.com/k1LoW/tbls/cmd/doc.go:56
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).execute
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:766
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:852
github.com/k1LoW/tbls/vendor/github.com/spf13/cobra.(*Command).Execute
        /root/go/src/github.com/k1LoW/tbls/vendor/github.com/spf13/cobra/command.go:800
github.com/k1LoW/tbls/cmd.Execute
        /root/go/src/github.com/k1LoW/tbls/cmd/root.go:53
main.main
        /root/go/src/github.com/k1LoW/tbls/main.go:34
runtime.main
        /usr/lib/golang/src/runtime/proc.go:195
runtime.goexit
        /usr/lib/golang/src/runtime/asm_amd64.s:2337

@k1LoW
Copy link
Owner Author

k1LoW commented Jul 25, 2018

@ymaeyama

MySQLのバージョンではなく、パスワード内で使われる文字列が問題のようです。

ありがとうございます!エラーログを見る限りその通りのようですね。。。

https://github.com/xo/dburl/blob/master/dburl_test.go#L99 にあるように # を urlencodeして試してもらってもよいですか?

@ymaeyama
Copy link

@k1LoW
おお、パスワードをURLEncodeしたらうまくいきました。
tblsのreadmeに書いておいていただけると助かります(忘れるので)

# DEBUG=1 tbls doc mysql://centos69_db_user1:QvAw1VhMVMORLhr%23@localhost:3306/tbls_mysql57 ./dbdoc
dbdoc/schema.png
dbdoc/users.png
dbdoc/README.md
dbdoc/users.md

@k1LoW
Copy link
Owner Author

k1LoW commented Jul 25, 2018

@ymaeyama
良かったです!長い時間お付き合いいただきありがとうございました!!! 🙏

@ymaeyama
Copy link

こちらこそ真摯に対応頂きありがとうございました。
大変ありがたかったです!

@k1LoW
Copy link
Owner Author

k1LoW commented Jul 25, 2018

Added !!! 7828d2e

@k1LoW k1LoW closed this as completed Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants