LoginSignup
3
1

More than 5 years have passed since last update.

GoのGithub APIv4 でreflect.Value.Interfaceというが出てエラーでハマった件

Last updated at Posted at 2018-07-17

GoでGithub API v4から取得したくてgithubqlを使ってみました。
https://qiita.com/siso9to/items/8ee0fc166902d5026649
https://github.com/shurcooL/githubv4

慣れないGoでAPIやJSONを扱うものは今後Goでは触りたくないと思ってしまいました。

そんな中でも強烈にハマったエラーが下記です。
reflect.Value.Interface: cannot return value obtained from unexported field or method

原因は非常に単純でプロパティ名も先頭の文字が大文字じゃないといけなかっただけでした。

type PullRequest struct {
    // ↓ok
    Title  githubv4.String
    // ↓ng
    url    githubv4.URI
}
3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1