code: func InitFactories(config *FactoryOpts) error {
  	factoriesInitOnce.Do(func() {
  		// Take some precautions on default opts
  		if config == nil {
  			config = GetDefaultOpts()
  		}
  
  		if config.ProviderName == "" {
  			config.ProviderName = "SW"
  		}
  
  		if config.SwOpts == nil {
  			config.SwOpts = GetDefaultOpts().SwOpts
  		}
  
  		// Initialize factories map
  		bccspMap = make(map[string]bccsp.BCCSP)
  
  		// Software-Based BCCSP
  		if config.SwOpts != nil {
  			f := &SWFactory{}
  			err := initBCCSP(f, config)
  			if err != nil {
  				factoriesInitError = errors.Wrapf(err, "Failed initializing BCCSP.")
  			}
  		}
  
  		// BCCSP Plugin
  		if config.PluginOpts != nil {
  			f := &PluginFactory{}
  			err := initBCCSP(f, config)
  			if err != nil {
  				factoriesInitError = errors.Wrapf(err, "Failed initializing PKCS11.BCCSP %s", factoriesInitError)
  			}
  		}
  
  		var ok bool
  		defaultBCCSP, ok = bccspMap[config.ProviderName]
  		if !ok {
  			factoriesInitError = errors.Errorf("%s\nCould not find default `%s` BCCSP", factoriesInitError, config.ProviderName)
  		}
  	})
  
  	return factoriesInitError
  }
docs: // InitFactories must be called before using factory interfaces
  // It is acceptable to call with config = nil, in which case
  // some defaults will get used
  // Error is returned only if defaultBCCSP cannot be found