This commit is contained in:
Philippe Caseiro 2022-06-29 16:30:20 +02:00
parent ba62abb2b0
commit 919b69ce4c
1 changed files with 7 additions and 22 deletions

View File

@ -1,7 +1,6 @@
package templater package templater
import ( import (
"bufio"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -17,31 +16,17 @@ type APKRepository struct {
} }
func (hr *APKRepository) urlIsPresent() (bool, error) { func (hr *APKRepository) urlIsPresent() (bool, error) {
f, err := os.Open(APKConfigFile) // read the whole file at once
b, err := ioutil.ReadFile(APKConfigFile)
if err != nil { if err != nil {
return false, err return err
} }
defer f.Close() s := string(b)
// //check whether s contains substring text
// Splits on newlines by default. if strings.Contains(s, hr.URL) {
scanner := bufio.NewScanner(f)
line := 1
for scanner.Scan() {
fmt.Printf("DBG:%s:%s:\n", scanner.Text(), hr.URL)
if strings.Contains(scanner.Text(), hr.URL) {
return true, nil return true, nil
} }
line++
}
fmt.Printf("END\n")
if err := scanner.Err(); err != nil {
return false, err
}
return false, nil return false, nil
} }
func (hr *APKRepository) Add() error { func (hr *APKRepository) Add() error {