MiSecurity / x-patrol

github泄露扫描系统
1.15k stars 303 forks source link

Github方法已不兼容 #17

Closed watsonwuh closed 5 years ago

watsonwuh commented 6 years ago

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 commented 6 years ago

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

netxfly commented 5 years ago

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