Skip to content

Commit 55307cf

Browse files
author
wintrmvte
committed
+ Url2Lines()
1 parent 80ce406 commit 55307cf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

net.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package coldfire
22

33
import (
4+
"bufio"
45
"fmt"
56
"io"
67
"io/ioutil"
@@ -10,13 +11,13 @@ import (
1011
"os"
1112
"strconv"
1213
"strings"
14+
1315
//"syscall"
14-
"time"
1516
"syscall"
17+
"time"
1618

1719
portscanner "github.com/anvie/port-scanner"
1820
"github.com/jackpal/gateway"
19-
2021
)
2122

2223
// GetGlobalIp is used to return the global Ip address of the machine.
@@ -283,4 +284,17 @@ func CloseListener(lst net.Listener){
283284
lst.Close()
284285
lst = nil
285286
}
287+
}
288+
289+
// Returns a slice with lines of file from URL
290+
func Url2Lines(url string) []string {
291+
resp, err := http.Get(url)
292+
Check(err)
293+
defer resp.Body.Close()
294+
var lns []string
295+
scn := bufio.NewScanner(resp.Body)
296+
for scn.Scan() {
297+
lns = append(lns, scn.Text())
298+
}
299+
return lns
286300
}

0 commit comments

Comments
 (0)