Skip to content

Instantly share code, notes, and snippets.

View lib.rs
use std::fs::File;
use std::io;
use std::mem;
pub fn close(file: &mut File) -> io::Result<()> {
imp::close(mem::replace(file, imp::invalid_file()))
}
#[cfg(unix)]
mod imp {
@phoet
phoet / gist:6021600
Created Jul 17, 2013
deutsche blacklist
View gist:6021600
[
"schiss",
"schiß",
"schlamm",
"schlampe",
"schleim",
"schließm",
"schlitz",
"schlong",
"schluck",
@elazarl
elazarl / cp.go
Last active Jun 27, 2020
Unfortunately, searching for "golang copy file" gives subtly wrong code snippets (e.g. https://groups.google.com/d/msg/golang-nuts/JNyQxQLyf5o/kbGnTUK32TkJ that don't check close error code). This is an attempt to copy file content from `src` to `dst`
View cp.go
package cp
import (
"io"
"os"
)
func cp(dst, src string) error {
s, err := os.Open(src)
if err != nil {