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

5.6节 redis Pool运行时报错 #1103

Open
fulln opened this issue Jul 22, 2019 · 0 comments
Open

5.6节 redis Pool运行时报错 #1103

fulln opened this issue Jul 22, 2019 · 0 comments

Comments

@fulln
Copy link

fulln commented Jul 22, 2019

go version go1.12.6 windows/amd64
执行5.6节中redis的代码时报错:

 go run .\redisin.go
# command-line-arguments
.\redisin.go:42:5: syntax error: unexpected newline, expecting comma or }

查询一番发现

func newPool(server string) *redis.Pool {

	return &redis.Pool{

		MaxIdle:     3,
		IdleTimeout: 240 * time.Second,

		Dial: func() (redis.Conn, error) {
			c, err := redis.Dial("tcp", server)
			if err != nil {
				return nil, err
			}
			return c, err
		},

		TestOnBorrow: func(c redis.Conn, t time.Time) error {
			_, err := c.Do("PING")
			return err
		}**,** //在多行 array、slice、map 语句中缺少 , 号  单行中可以省略但是多行不能省略
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant