Try 07
This commit is contained in:
parent
bb82f70c5a
commit
e7432d7fed
|
@ -1,6 +1,7 @@
|
|||
package templater
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -16,17 +17,31 @@ type APKRepository struct {
|
|||
}
|
||||
|
||||
func (hr *APKRepository) urlIsPresent() (bool, error) {
|
||||
// read the whole file at once
|
||||
b, err := ioutil.ReadFile(APKConfigFile)
|
||||
f, err := os.Open(APKConfigFile)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
s := string(b)
|
||||
// //check whether s contains substring text
|
||||
if strings.Contains(s, hr.URL) {
|
||||
return true, nil
|
||||
defer f.Close()
|
||||
|
||||
// Splits on newlines by default.
|
||||
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
|
||||
}
|
||||
|
||||
line++
|
||||
}
|
||||
fmt.Printf("END\n")
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return false, nil
|
||||
|
||||
}
|
||||
|
||||
func (hr *APKRepository) Add() error {
|
||||
|
|
Loading…
Reference in New Issue