mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-13 21:26:16 +01:00
init-exe template: add flushing to the buffered writer
This commit is contained in:
parent
cbac7a0194
commit
616f65df75
1 changed files with 9 additions and 7 deletions
|
|
@ -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" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue