I want to implement this array in main function above but how?
hosts := []string{"[email protected]", "[email protected]"}
Content of JSON file:
inanzzz@inanzzz-VirtualBox:~/go$ go run reader.go < hosts.txt
{
{
"username":"inanzzz1",
"ip":"100.79.154.22"
},
{
"username":"inanzzz2",
"ip":"200.79.190.11"
}
}
GO file which reads the JSON file above:
package main
import (
"os"
"bufio"
"fmt"
)
func main() {
r := bufio.NewReader(os.Stdin)
line, err := r.ReadString('\n')
for i := 1; err == nil; i++ {
//fmt.Printf("Line %d: %s", i, line)
fmt.Printf(line)
line, err = r.ReadString('\n')
}
}