Skip to content

Instantly share code, notes, and snippets.

elazarl / cp.go
Last active Jun 27, 2020
Unfortunately, searching for "golang copy file" gives subtly wrong code snippets (e.g. 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 (
func cp(dst, src string) error {
s, err := os.Open(src)
if err != nil {
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()))
mod imp {
phoet / gist:6021600
Created Jul 17, 2013
deutsche blacklist
View gist:6021600