...

Source file src/github.com/gobuffalo/flect/singular_rules.go

Documentation: github.com/gobuffalo/flect

     1  package flect
     2  
     3  var singularRules = []rule{}
     4  
     5  // AddSingular adds a rule that will replace the given suffix with the replacement suffix.
     6  // The name is confusing. This function will be deprecated in the next release.
     7  func AddSingular(ext string, repl string) {
     8  	InsertSingularRule(ext, repl)
     9  }
    10  
    11  // InsertSingularRule inserts a rule that will replace the given suffix with
    12  // the repl(acement) at the beginning of the list of the singularize rules.
    13  func InsertSingularRule(suffix, repl string) {
    14  	singularMoot.Lock()
    15  	defer singularMoot.Unlock()
    16  
    17  	singularRules = append([]rule{{
    18  		suffix: suffix,
    19  		fn:     simpleRuleFunc(suffix, repl),
    20  	}}, singularRules...)
    21  
    22  	singularRules = append([]rule{{
    23  		suffix: repl,
    24  		fn:     noop,
    25  	}}, singularRules...)
    26  }
    27  

View as plain text