From 96add147b997e97e335436147f11f3fdc5f8164a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 19 Jul 2015 16:23:32 -0700 Subject: [PATCH] Don't export the config repo structure --- cmd/fdroidcl/main.go | 8 ++++---- cmd/fdroidcl/update.go | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/fdroidcl/main.go b/cmd/fdroidcl/main.go index 3eb19f0..716b4fb 100644 --- a/cmd/fdroidcl/main.go +++ b/cmd/fdroidcl/main.go @@ -47,17 +47,17 @@ func configPath() string { return filepath.Join(mustConfig(), "config.json") } -type Repo struct { +type repo struct { ID string `json:"id"` URL string `json:"url"` } type userConfig struct { - Repos []Repo `json:"repos"` + Repos []repo `json:"repos"` } var config = userConfig{ - Repos: []Repo{ + Repos: []repo{ { ID: "f-droid", URL: "https://f-droid.org/repo", @@ -80,7 +80,7 @@ func readConfig() error { return nil } -func mustOneRepo() *Repo { +func mustOneRepo() *repo { if len(config.Repos) != 1 { log.Fatalf("Exactly one repo is needed") } diff --git a/cmd/fdroidcl/update.go b/cmd/fdroidcl/update.go index c2d7f87..c69942b 100644 --- a/cmd/fdroidcl/update.go +++ b/cmd/fdroidcl/update.go @@ -28,15 +28,15 @@ func init() { } func runUpdate(args []string) { - if err := updateIndex(); err != nil { + r := mustOneRepo() + if err := updateRepo(r); err != nil { log.Fatalf("Could not update index: %v", err) } } -func updateIndex() error { - repo := mustOneRepo() - url := fmt.Sprintf("%s/%s", repo.URL, "index.jar") - if err := downloadEtag(url, indexPath(repo.ID), nil); err != nil { +func updateRepo(r *repo) error { + url := fmt.Sprintf("%s/%s", r.URL, "index.jar") + if err := downloadEtag(url, indexPath(r.ID), nil); err != nil { return err } return nil @@ -106,8 +106,8 @@ func indexPath(name string) string { } func mustLoadIndex() *fdroidcl.Index { - repo := mustOneRepo() - p := indexPath(repo.ID) + r := mustOneRepo() + p := indexPath(r.ID) f, err := os.Open(p) if err != nil { log.Fatalf("Could not open index file: %v", err)