diff options
| author | Loris Cro <kappaloris@gmail.com> | 2022-08-04 21:12:42 +0200 |
|---|---|---|
| committer | Loris Cro <kappaloris@gmail.com> | 2022-08-04 21:12:42 +0200 |
| commit | 616f65df750f53e6334cc5ed2c8f4b5668d573f2 (patch) | |
| tree | 687c451b525e6b0c039515414f64ab097a6fff2a /lib/init-exe | |
| parent | cbac7a019473055aaf6b1a87b4b57b9872ed54b4 (diff) | |
| download | zig-616f65df750f53e6334cc5ed2c8f4b5668d573f2.tar.gz zig-616f65df750f53e6334cc5ed2c8f4b5668d573f2.zip | |
init-exe template: add flushing to the buffered writer
Diffstat (limited to 'lib/init-exe')
| -rw-r--r-- | lib/init-exe/src/main.zig | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/init-exe/src/main.zig b/lib/init-exe/src/main.zig index 45d075af88..c8a3f67dd0 100644 --- a/lib/init-exe/src/main.zig +++ b/lib/init-exe/src/main.zig @@ -4,14 +4,16 @@ pub fn main() !void { // Prints to stderr (it's a shortcut based on `std.io.getStdErr()`) std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); - // Prints to stdout - const unbuffered_out = std.io.getStdOut().writer(); - const out = std.io.bufferedWriter(unbuffered_out).writer(); - try out.print("Run `zig build test` to run the tests.\n", .{}); - - // Stdout is for the actual output of your application, for example if you + // stdout is for the actual output of your application, for example if you // are implementing gzip, then only the compressed bytes should be sent to - // stdout, not any debugging messages! + // stdout, not any debugging messages. + const stdout_file = std.io.getStdOut().writer(); + var bw = std.io.bufferedWriter(stdout_file); + const stdout = bw.writer(); + + try stdout.print("Run `zig build test` to run the tests.\n", .{}); + + try bw.flush(); // don't forget to flush! } test "simple test" { |
