code: func (g *RuleGroups) Validate() (errs []error) {
  	set := map[string]struct{}{}
  
  	for _, g := range g.Groups {
  		if g.Name == "" {
  			errs = append(errs, errors.Errorf("Groupname should not be empty"))
  		}
  
  		if _, ok := set[g.Name]; ok {
  			errs = append(
  				errs,
  				errors.Errorf("groupname: \"%s\" is repeated in the same file", g.Name),
  			)
  		}
  
  		set[g.Name] = struct{}{}
  
  		for i, r := range g.Rules {
  			for _, err := range r.Validate() {
  				var ruleName string
  				if r.Alert != "" {
  					ruleName = r.Alert
  				} else {
  					ruleName = r.Record
  				}
  				errs = append(errs, &Error{
  					Group:    g.Name,
  					Rule:     i,
  					RuleName: ruleName,
  					Err:      err,
  				})
  			}
  		}
  	}
  
  	return errs
  }
docs: // Validate validates all rules in the rule groups.