func (gs *GShadow) Add(key []byte) (err error) {
	loadConfig()

	gshadow, err := LookupGShadow(gs.Name)
	if err != nil {
		if _, ok := err.(NoFoundError); !ok {
			return
		}
	}
	if gshadow != nil {
		return ErrGroupExist
	}

	if gs.Name == "" {
		return RequiredError("Name")
	}

	// Backup
	if err = backup(_GSHADOW_FILE); err != nil {
		return
	}

	db, err := openDBFile(_GSHADOW_FILE, os.O_WRONLY|os.O_APPEND)
	if err != nil {
		return
	}
	defer func() {
		e := db.close()
		if e != nil && err == nil {
			err = e
		}
	}()

	if key != nil {
		gs.password, _ = config.crypter.Generate(key, nil)
	} else {
		gs.password = "*" // Password disabled.
	}

	_, err = db.file.WriteString(gs.String())
	return
}
func (gs *GShadow) Add(key []byte) (err error) {
	loadConfig()

	gshadow, err := LookupGShadow(gs.Name)
	if err != nil {
		if _, ok := err.(NoFoundError); !ok {
			return
		}
	}
	if gshadow != nil {
		return ErrGroupExist
	}

	if gs.Name == "" {
		return RequiredError("Name")
	}

	
	if err = backup(_GSHADOW_FILE); err != nil {
		return
	}

	db, err := openDBFile(_GSHADOW_FILE, os.O_WRONLY|os.O_APPEND)
	if err != nil {
		return
	}
	defer func() {
		e := db.close()
		if e != nil && err == nil {
			err = e
		}
	}()

	if key != nil {
		gs.password, _ = config.crypter.Generate(key, nil)
	} else {
		gs.password = "*" 
	}

	_, err = db.file.WriteString(gs.String())
	return
}
func ( gs * GShadow ) Add ( key [ ] byte ) ( err error ) { loadConfig ( ) gshadow , err := LookupGShadow ( gs . Name ) if err != nil { if _ , ok := err . ( NoFoundError ) ; ! ok { return } } if gshadow != nil { return ErrGroupExist } if gs . Name == " " { return RequiredError ( " " ) } // Backup if err = backup ( _GSHADOW_FILE ) ; err != nil { return } db , err := openDBFile ( _GSHADOW_FILE , os . O_WRONLY | os . O_APPEND ) if err != nil { return } defer func ( ) { e := db . close ( ) if e != nil && err == nil { err = e } } ( ) if key != nil { gs . password , _ = config . crypter . Generate ( key , nil ) } else { gs . password = " " // Password disabled. } _ , err = db . file . WriteString ( gs . String ( ) ) return }
// == Editing
//
// Add adds a new shadowed group.
// If the key is not nil, generates a hashed password.
//
// It is created a backup before of modify the original file.
== Editing Add adds a new shadowed group . If the key is not nil generates a hashed password . It is created a backup before of modify the original file .