// Create takes the provided Go object, converts it to a JSON string
// (or mimetype), then stores it under the given object name.
Create takes the provided Go object, converts it to a JSON string
(or mimetype), then stores it under the given object name.
// Create takes the provided Go object converts it to a JSON string // ( or mimetype ) then stores it under the given object name .
func (fs *FileStore) Create(name string, gobj interface{}) (err error) {
	if fs.Exists(name) {
		return fmt.Errorf("File Object Exists")
	}
	stobj := gobj
	jbuf, err := json.MarshalIndent(stobj, "  ", "  ")
	if err != nil {
		return err
	}
	path := fs.Basepath + "/" + name
	err = ioutil.WriteFile(path, jbuf, 0644)
	if err != nil {
		return fmt.Errorf("  Store.Object write failed %s -> %v",
			path, err)
	}
	return err
}
func ( fs * FileStore ) Create ( name string , gobj interface { } ) ( err error ) { if fs . Exists ( name ) { return fmt . Errorf ( " " ) } stobj := gobj jbuf , err := json . MarshalIndent ( stobj , " " , " " ) if err != nil { return err } path := fs . Basepath + " " + name err = ioutil . WriteFile ( path , jbuf , 0644 ) if err != nil { return fmt . Errorf ( " " , path , err ) } return err }
Create takes the provided Go object, converts it to a JSON string
(or mimetype), then stores it under the given object name.
Create takes the provided Go object converts it to a JSON string ( or mimetype ) then stores it under the given object name .
// turn the interface into and object then JSONify it // Now write to the file