Last active
December 24, 2021 02:22
-
-
Save Subi/a3e0f103760656d41b797b9957b2d85f to your computer and use it in GitHub Desktop.
Revisions
-
Subi revised this gist
Dec 24, 2021 . No changes.There are no files selected for viewing
-
Subi created this gist
Dec 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ package formatter import ( "fmt" "io/ioutil" "log" "strings" ) type Formatter interface { Read() string Format(string) string } type proxyFormatter struct { Proxies []string } func NewProxyFormatter() Formatter { return &proxyFormatter{} } func (p *proxyFormatter) Read() string { content, err := ioutil.ReadFile("proxies.txt") if err != nil { log.Fatalln("Error occurred reading proxies.txt file", err.Error()) } return string(content) } func (p *proxyFormatter) Format(content string) (res string) { proxies := strings.Split(content, "\n") for _, proxy := range proxies { res += fmt.Sprintf("- %s \n", proxy) } return } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ package main import ( "log" f "proxyformatter/formatter" ) func main() { pf := f.NewProxyFormatter() resp := pf.Read() results := pf.Format(resp) log.Println(results) }