func NewDecoderWithPath(path string, flags Flag) (*Decoder, error) {
	db := C.magic_open(C.int(0))
	if db == nil {
		return nil, errors.New("error opening magic")
	}
	d := &Decoder{db: db}
	if code := C.magic_setflags(db, C.int(flags)); code != 0 {
		errstr := C.GoString(C.magic_error(d.db))
		d.Close()
		return nil, errors.New(errstr)
	}

	var code C.int
	if path == "" {
		code = C.magic_load(db, nil)
	} else {
		code = C.magic_load(db, C.CString(path))
	}
	if code != 0 {
		errstr := C.GoString(C.magic_error(d.db))
		d.Close()
		return nil, errors.New(errstr)
	}
	return d, nil
}
// NewDecoder creates a detector that uses libmagic. It initializes
// the opens the magicmime database with the specified flags. Upon
// success users are expected to call Close on the returned Decoder
// when it is no longer needed. Access to the magicmime
// database is not synchronized; the magicmime database file-descriptor
// is referenced through a global variable.  Add mutex Lock/Unlock around
// the magicmime functions if using multiple goroutines.
NewDecoder creates a detector that uses libmagic. It initializes
the opens the magicmime database with the specified flags. Upon
success users are expected to call Close on the returned Decoder
when it is no longer needed. Access to the magicmime
database is not synchronized; the magicmime database file-descriptor
is referenced through a global variable.  Add mutex Lock/Unlock around
the magicmime functions if using multiple goroutines.
// NewDecoder creates a detector that uses libmagic . It initializes // the opens the magicmime database with the specified flags . Upon // success users are expected to call Close on the returned Decoder // when it is no longer needed . Access to the magicmime // database is not synchronized ; the magicmime database file - descriptor // is referenced through a global variable . Add mutex Lock / Unlock around // the magicmime functions if using multiple goroutines .
func NewDecoderWithPath(path string, flags Flag) (*Decoder, error) {
	db := C.magic_open(C.int(0))
	if db == nil {
		return nil, errors.New("error opening magic")
	}
	d := &Decoder{db: db}
	if code := C.magic_setflags(db, C.int(flags)); code != 0 {
		errstr := C.GoString(C.magic_error(d.db))
		d.Close()
		return nil, errors.New(errstr)
	}
	var code C.int
	if path == "" {
		code = C.magic_load(db, nil)
	} else {
		code = C.magic_load(db, C.CString(path))
	}
	if code != 0 {
		errstr := C.GoString(C.magic_error(d.db))
		d.Close()
		return nil, errors.New(errstr)
	}
	return d, nil
}
func NewDecoderWithPath ( path string , flags Flag ) ( * Decoder , error ) { db := C . magic_open ( C . int ( 0 ) ) if db == nil { return nil , errors . New ( " " ) } d := & Decoder { db : db } if code := C . magic_setflags ( db , C . int ( flags ) ) ; code != 0 { errstr := C . GoString ( C . magic_error ( d . db ) ) d . Close ( ) return nil , errors . New ( errstr ) } var code C . int if path == " " { code = C . magic_load ( db , nil ) } else { code = C . magic_load ( db , C . CString ( path ) ) } if code != 0 { errstr := C . GoString ( C . magic_error ( d . db ) ) d . Close ( ) return nil , errors . New ( errstr ) } return d , nil }
NewDecoder creates a detector that uses libmagic.
NewDecoder creates a detector that uses libmagic .