Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package main
import (
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
return lines, scanner.Err()
func main() {
values, err := readLines("---yourfilepath---")
if err != nil {
log.Fatalf("readLines: %s", err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment