-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: have a custom /dev/null implementation
This fix reading and writing to /dev/null on Windows, where this file is not available. It may also add a very minimal performance improvement on other plataforms, since now interp don't need to open and redirect to a real file anymore. Reference: #141
- Loading branch information
1 parent
d002e24
commit b19ade2
Showing
3 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package interp | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
var _ io.ReadWriteCloser = devNull{} | ||
|
||
type devNull struct{} | ||
|
||
func (devNull) Read(_ []byte) (int, error) { | ||
return 0, io.EOF | ||
} | ||
|
||
func (devNull) Write(p []byte) (int, error) { | ||
return len(p), nil | ||
} | ||
|
||
func (devNull) Close() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters