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

Github方法已不兼容 #17

Closed
watsonwuh opened this issue Sep 13, 2018 · 2 comments
Closed

Github方法已不兼容 #17

watsonwuh opened this issue Sep 13, 2018 · 2 comments

Comments

@watsonwuh
Copy link

go build main.go 提示:

x-patrol/models

models/github.go:97:35: response.Remaining undefined (type *github.Response has no field or method Remaining)
models/github.go:98:31: response.Reset undefined (type *github.Response has no field or method Reset)
models/github.go:99:31: response.Limit undefined (type *github.Response has no field or method Limit)

@simba83524
Copy link

这个修改一下就可以了response.Rate.Remaining

@netxfly
Copy link
Collaborator

netxfly commented Nov 30, 2018

github.com/google/go-github/github更新过了,数据结构有变化:

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go build main.go

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go get -u github.com/google/go-github/github
# cd /data/code/golang/src/github.com/google/go-github; git pull --ff-only
From https://github.com/google/go-github
   922ceac..8d8132c  master                -> origin/master
 * [new branch]      revert-844-teamreview -> origin/revert-844-teamreview
 * [new tag]         v10.0.0               -> v10.0.0
 * [new tag]         v11.0.0               -> v11.0.0
 * [new tag]         v12.0.0               -> v12.0.0
 * [new tag]         v13.0.0               -> v13.0.0
 * [new tag]         v14.0.0               -> v14.0.0
 * [new tag]         v2.0.0                -> v2.0.0
 * [new tag]         v3.0.0                -> v3.0.0
 * [new tag]         v4.0.0                -> v4.0.0
 * [new tag]         v5.0.0                -> v5.0.0
 * [new tag]         v6.0.0                -> v6.0.0
 * [new tag]         v7.0.0                -> v7.0.0
 * [new tag]         v8.0.0                -> v8.0.0
 * [new tag]         v9.0.0                -> v9.0.0
 * [new tag]         v15.0.0               -> v15.0.0
 * [new tag]         v16.0.0               -> v16.0.0
 * [new tag]         v17.0.0               -> v17.0.0
 * [new tag]         v18.0.0               -> v18.0.0
 * [new tag]         v18.1.0               -> v18.1.0
 * [new tag]         v18.2.0               -> v18.2.0
 * [new tag]         v19.0.0               -> v19.0.0
 * [new tag]         v19.1.0               -> v19.1.0
error: Your local changes to the following files would be overwritten by merge:
	github/github.go
	github/search.go
Please commit your changes or stash them before you merge.
Aborting
Updating 922ceac..8d8132c
package github.com/google/go-github/github: exit status 1

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ rm -fr ../github.com/google/go-github

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go get -u github.com/google/go-github/github

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go build main.go
# x-patrol/models
models/github.go:97:35: response.Remaining undefined (type *github.Response has no field or method Remaining)
models/github.go:98:31: response.Reset undefined (type *github.Response has no field or method Reset)
models/github.go:99:31: response.Limit undefined (type *github.Response has no field or method Limit)

models/github.go中的代码改为以下就可以了:

func UpdateRate(token string, response *github.Response) (error) {
	githubToken := new(GithubToken)
	has, err := Engine.Table("github_token").Where("token=?", token).Get(githubToken)
	if err == nil && has {
		id := githubToken.Id
		githubToken.Remaining = response.Rate.Remaining
		githubToken.Reset = response.Rate.Reset.Time
		githubToken.Limit = response.Rate.Limit
		Engine.ID(id).Update(githubToken)
	}
	return err
}

util/githubsearch/gitclient.go:160:文件中相应的地方也要修改

$ go get -u github.com/google/go-github/github

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go build main.go
# x-patrol/models
models/github.go:97:35: response.Remaining undefined (type *github.Response has no field or method Remaining)
models/github.go:98:31: response.Reset undefined (type *github.Response has no field or method Reset)
models/github.go:99:31: response.Limit undefined (type *github.Response has no field or method Limit)

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go build main.go
# x-patrol/util/githubsearch
util/githubsearch/gitclient.go:160:10: resp.Remaining undefined (type *github.Response has no field or method Remaining)

hartnett at hartnettdeMacBook-Pro in /data/code/golang/src/x-patrol (mi_dev)
$ go build main.go

@netxfly netxfly closed this as completed Nov 30, 2018
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

3 participants