1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

20191215 code improvements (#790)

* Upgrade godo to latest
* Fix a bunch of issues found by
* Running staticcheck on a codebase for the first time is a sobering experience
* go mod tidy
* More static improvements

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2019-12-16 20:25:29 -08:00
committed by GitHub
parent e71038ccf2
commit 3a388fba23
65 changed files with 236 additions and 815 deletions

View File

@@ -1,6 +1,7 @@
package googleanalytics
import (
"context"
"fmt"
"io/ioutil"
"log"
@@ -8,10 +9,10 @@ import (
"time"
"github.com/wtfutil/wtf/utils"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
gaV3 "google.golang.org/api/analytics/v3"
gaV4 "google.golang.org/api/analyticsreporting/v4"
"google.golang.org/api/option"
)
type websiteReport struct {
@@ -56,12 +57,13 @@ func buildNetClient(secretPath string) *http.Client {
log.Fatalf("Unable to get config from JSON. %v", err)
}
return jwtConfig.Client(oauth2.NoContext)
return jwtConfig.Client(context.Background())
}
func makeReportServiceV3(secretPath string) (*gaV3.Service, error) {
var netClient = buildNetClient(secretPath)
svc, err := gaV3.New(netClient)
client := buildNetClient(secretPath)
svc, err := gaV3.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
log.Fatalf("Failed to create v3 Google Analytics Reporting Service")
}
@@ -70,8 +72,8 @@ func makeReportServiceV3(secretPath string) (*gaV3.Service, error) {
}
func makeReportServiceV4(secretPath string) (*gaV4.Service, error) {
var netClient = buildNetClient(secretPath)
svc, err := gaV4.New(netClient)
client := buildNetClient(secretPath)
svc, err := gaV4.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
log.Fatalf("Failed to create v4 Google Analytics Reporting Service")
}