From ca671e035f98cc43ce2172d4a205198afb7a8b94 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 8 Jul 2019 00:12:25 +0200 Subject: [PATCH] updated comments in structs, updated error handler --- functions.go | 11 ++++------- types.go | 10 +++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/functions.go b/functions.go index 1d36deb..180d5bc 100644 --- a/functions.go +++ b/functions.go @@ -167,10 +167,8 @@ func MigrateReposToGogs(config *Config, repolist []GitHubRepo) { client.Timeout = config.globalconfig.RequestTimeout - resp, err := client.Do(req) - HandleError(err) - - fmt.Println(resp.StatusCode) + _, err = client.Do(req) + HandleFatalError(err) } else { fmt.Println(fmt.Sprintf("Not migrating, %s exists in gogs", elem.Name)) } @@ -178,11 +176,10 @@ func MigrateReposToGogs(config *Config, repolist []GitHubRepo) { } // HandleError handles errors to return err -func HandleError(err error) error { +func HandleError(err error) { if err != nil { - return err + log.Println(err) } - return nil } // HandleFatalError fatal errors diff --git a/types.go b/types.go index fdcecef..15d0adc 100644 --- a/types.go +++ b/types.go @@ -14,7 +14,7 @@ type GogsOrg struct { Username string `json:"username"` } -// GogsMigrateRepo ... +// GogsMigrateRepo defines the repo to migrate type GogsMigrateRepo struct { Name string CloneURL string @@ -22,20 +22,20 @@ type GogsMigrateRepo struct { Mirror bool } -// Config ... +// Config merge all config elements type Config struct { globalconfig GlobalConfig gogsconfig GogsConfig githubconfig GitHubConfig } -// GlobalConfig ... +// GlobalConfig is the global config of github-to-gogs type GlobalConfig struct { RequestTimeout time.Duration UserAgent string } -// GitHubConfig ... +// GitHubConfig is the GitHub config type GitHubConfig struct { StarsPages string MaxPagesNumber int @@ -44,7 +44,7 @@ type GitHubConfig struct { ContentType string } -// GogsConfig ... +// GogsConfig is the Gogs config type GogsConfig struct { UID int Username string