func Copy(ctx context.Context, dst io.Writer, src io.Reader, buf []byte) (err error) {
	cancel := false
	c := make(chan error)
	go func() {
		c <- copyWithCancelation(dst, src, buf, &cancel)
	}()
	select {
	case err = <-c:
		return err
	case <-ctx.Done():
		cancel = true
		<-c
		return ctx.Err()
	}
}
Copy reads bytes to buffer from source and write to destination from buffer with cancelation signal.

Params:
ctx:
Google's Context type which carries deadlines, cacelation signals,
and other request-scoped values across API boundaries and between processes.
See https://godoc.org/golang.org/x/net/context for more.
dst: Destination.
src: Source.
buf: Buffer(length should >= 0).
package ctxcopy
import (
	"fmt"
	"io"
	"golang.org/x/net/context"
)
const (
	zeroBufferLenError string = "Buffer length is 0."
	canceledStr string = "Copy operation is canceled."
)
func copyWithCancelation(dst io.Writer, src io.Reader, buf []byte, cancel *bool) (err error) {
	if len(buf) == 0 {
		return fmt.Errorf(zeroBufferLenError)
	}
	for {
		if cancel != nil && (*cancel) {
			return fmt.Errorf(canceledStr)
		}
		n, err := src.Read(buf)
		if err != nil && err != io.EOF {
			return err
		}
		if n == 0 {
			break
		}
		if _, err := dst.Write(buf[:n]); err != nil {
			return err
		}
	}
	return nil
}