Generation

generate functionSat, 12 Nov 2022

Read file

func ReadFile(filename string) ([]string, error) { f, err := os.Open(filename) if err != nil { return nil, err } defer f.Close() lines := []string{} scanner := bufio.NewScanner(f) for scanner.Scan() { lines = append(lines, scanner.Text()) } return lines, scanner.Err() }

Questions about programming?Chat with your personal AI assistant