small fixses

This commit is contained in:
Radu Ioan Fericean
2013-05-30 18:26:27 +03:00
parent 6966a85e68
commit 84f489a73a
3 changed files with 13 additions and 6 deletions

View File

@@ -18,6 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package utils
import (
"crypto/sha1"
"fmt"
)
// Returns first non empty string out of vals. Useful to extract defaults
func FirstNonEmpty(vals ...string) string {
for _, val := range vals {
@@ -27,3 +32,9 @@ func FirstNonEmpty(vals ...string) string {
}
return ""
}
func FSCgrId(uuid string) string {
hasher := sha1.New()
hasher.Write([]byte(uuid))
return fmt.Sprintf("%x", hasher.Sum(nil))
}