github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/mapp/mapp.go (about)

     1  package mapp
     2  
     3  // GetStringOr returns the value associated to the key,
     4  // or return defValue when value does not exit, or it is empty.
     5  func GetStringOr(m map[string]string, key, defValue string) string {
     6  	if v, ok := m[key]; ok && v != "" {
     7  		return v
     8  	}
     9  
    10  	return defValue
    11  }