Skip to content

Commit

Permalink
Switch from io.Writer to explicit *os.File (shaving off a tiny am…
Browse files Browse the repository at this point in the history
…ount more bytes)
  • Loading branch information
tianon committed Mar 20, 2024
1 parent 64a0cd9 commit ccc5c46
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main // import "github.com/tianon/gosu"

import (
"io"
"os"
"os/exec"
"runtime"
Expand Down Expand Up @@ -34,7 +33,7 @@ Usage: ` + self + ` user-spec command [args]
return t[1:]
}

func exit(code int, w io.Writer, ss ...string) {
func exit(code int, w *os.File, ss ...string) {

This comment has been minimized.

Copy link
@AlexanderYastrebov

AlexanderYastrebov Mar 20, 2024

Contributor

You may also use syscall.Exit() and syscall.Stat() to save another 250 bytes 🤣

This comment has been minimized.

Copy link
@tianon

tianon Mar 21, 2024

Author Owner

I love this line of thinking -- I guess os.Exit is just a wrapper around syscall.Exit in the end?

This comment has been minimized.

Copy link
@tianon

tianon Mar 21, 2024

Author Owner

https://cs.opensource.google/go/go/+/refs/tags/go1.22.1:src/os/proc.go;l=62

Ah, it's pretty short and possibly important (if we ever want coverage/profiling, for example), so probably not worth going that far. 😇

for i, s := range ss {
if i > 0 {
w.Write([]byte{' '})
Expand Down

0 comments on commit ccc5c46

Please sign in to comment.