/* GoCheese -- Python private package repository and caching proxy Copyright (C) 2019 Sergey Matveev 2019 Elena Balakhonova This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package main import ( "io/ioutil" "log" "strings" ) func refreshPasswd() { passwd, err := ioutil.ReadFile(*passwdPath) if err != nil { log.Fatal(err) } for i, credentials := range strings.Split(strings.TrimRight(string(passwd), "\n"), "\n") { splitted := strings.Split(credentials, ":") if len(splitted) != 2 { log.Fatalf("%s:%d: Wrong login:password format", *passwdPath, i) } login := splitted[0] if _, exists := passwords[login]; exists { log.Fatalf("%s:%d: %s: already exists", *passwdPath, i, login) } _, auther, err := strToAuther(splitted[1]) if err != nil { log.Fatalf("%s:%d: %s: %s", *passwdPath, i, login, err) } passwords[login] = auther log.Println("Added password for " + login) } }