I am trying to use service account with go bigquery client. For some reason, there's no Go example of how to pass a service file in when you make a client. I see here https://cloud.google.com/docs/authentication/production but this pattern doesn't follow anything shown. It also isn't shown at https://godoc.org/cloud.google.com/go/bigquery
I have
//bigquery_caller.go
package main
import "C"
import "fmt"
import "cloud.google.com/go/bigquery"
import "golang.org/x/net/context"
func main() {
ctx := context.Background()
client, err := bigquery.NewClient(ctx, "project-name")
if err != nil {
fmt.Println("Had an error")
}
q := client.Query(`
select * from mytables
`)
it, err := q.Read(ctx)
fmt.Println(it)
fmt.Println(err)
}
The code works, I get
googleapi: Error 403: Access Denied: Project project-name:
How can I pass a service key file in to go client?