func Init(config *config.BoltConfig) (Bolt, error) {
	db := Bolt{}

	store, err := bolt.Open(config.Path, 0600, &bolt.Options{Timeout: 1 * time.Second})
	if err != nil {
		return Bolt{}, err
	}

	// Create root bucket if not exists
	err = store.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists([]byte(storage.LinksBucket))
		if err != nil {
			return err
		}

		return nil
	})
	if err != nil {
		return Bolt{}, err
	}

	db.store = store
	log.Info().Str("path", config.Path).Msg("connected to bolt db")

	return db, nil
}
// Init creates a new boltdb with given settings
Init creates a new boltdb with given settings
// Init creates a new boltdb with given settings
func Init(config *config.BoltConfig) (Bolt, error) {
	db := Bolt{}
	store, err := bolt.Open(config.Path, 0600, &bolt.Options{Timeout: 1 * time.Second})
	if err != nil {
		return Bolt{}, err
	}
	err = store.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists([]byte(storage.LinksBucket))
		if err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return Bolt{}, err
	}
	db.store = store
	log.Info().Str("path", config.Path).Msg("connected to bolt db")
	return db, nil
}
func Init ( config * config . BoltConfig ) ( Bolt , error ) { db := Bolt { } store , err := bolt . Open ( config . Path , 0600 , & bolt . Options { Timeout : 1 * time . Second } ) if err != nil { return Bolt { } , err } err = store . Update ( func ( tx * bolt . Tx ) error { _ , err := tx . CreateBucketIfNotExists ( [ ] byte ( storage . LinksBucket ) ) if err != nil { return err } return nil } ) if err != nil { return Bolt { } , err } db . store = store log . Info ( ) . Str ( " " , config . Path ) . Msg ( " " ) return db , nil }
Init creates a new boltdb with given settings
Init creates a new boltdb with given settings
// Create root bucket if not exists