slurp reads a whole file into a string. os.ReadFile is the Go function and returns the bytes plus an error. fmt.Sprintf with %s turns those bytes into a string. print does not add a newline, so the file's own newline ends the line.
slurp
os.ReadFile
fmt.Sprintf
%s
print
(let [[dir _] (os.MkdirTemp "" "glj-read") path (path:filepath.Join dir "note.txt")] (os.WriteFile path "hello\nworld\n" 0644) (print (slurp path)) (let [[data err] (os.ReadFile path)] (println (nil? err)) (print (fmt.Sprintf "%s" data))) (os.RemoveAll dir))
0644 is an octal literal, the usual file mode for a user-writable file. A missing file makes ReadFile return an error value. slurp throws.
0644
ReadFile
Both reads print the same two lines.
$ glj reading-files.glj hello world true hello world
Next example: Writing Files.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.