Skip to content

Instantly share code, notes, and snippets.

@elazarl
elazarl / cp.go
Last active June 27, 2020 14:42
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`
package cp
import (
"io"
"os"
)
func cp(dst, src string) error {
s, err := os.Open(src)
if err != nil {
@phoet
phoet / gist:6021600
Created July 17, 2013 15:23
deutsche blacklist
[
"schiss",
"schiß",
"schlamm",
"schlampe",
"schleim",
"schließm",
"schlitz",
"schlong",
"schluck",
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 {