Created
March 26, 2019 00:18
-
-
Save leitu/aea604680801ce9037e1bffd3ef998a0 to your computer and use it in GitHub Desktop.
paractise for coding
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"strings" | |
) | |
const data = `66.249.65.159 - - [06/Nov/2014:19:10:38 +0600] "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1" 404 177 | |
66.249.65.3 - - [06/Nov/2014:19:11:24 +0600] "GET /?q=%E0%A6%AB%E0%A6%BE%E0%A7%9F%E0%A6%BE%E0%A6%B0 HTTP/1.1" 200 4223" | |
66.249.65.62 - - [06/Nov/2014:19:12:14 +0600] "GET /?q=%E0%A6%A6%E0%A7%8B%E0%A7%9F%E0%A6%BE HTTP/1.1" 200 4356` | |
func main() { | |
matchip := "66.249.65.159" | |
output := strings.NewReader(data) | |
fmt.Println(output) | |
newout, err := ioutil.ReadAll(output) | |
if err != nil { | |
fmt.Println(err) | |
} | |
toConvert := strings.Replace(string(newout), "\n", " ", -1) | |
fmt.Println(toConvert) | |
toString := strings.Split(toConvert, " ") | |
fmt.Println(toString) | |
for i := 0; i < len(toString); { | |
fmt.Println(toString[i]) | |
if matchip == toString[i] { | |
fmt.Println("find strings") | |
break | |
} | |
i = i + 10 | |
fmt.Println("didn't exist") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment