Example #1
0
// Create creates a new FITS file in write-only mode
func Create(w io.Writer) (*File, error) {
	var err error
	type namer interface {
		Name() string
	}
	name := ""
	if w, ok := w.(namer); ok {
		name = w.Name()
	}

	f := &File{
		enc:     NewEncoder(w),
		name:    name,
		mode:    WriteOnly,
		hdus:    make([]HDU, 0, 1),
		closers: make([]io.Closer, 0, 1),
	}

	if ww, ok := w.(io.Closer); ok {
		f.closers = append(f.closers, ww)
	}

	return f, err
}