github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/wordsmith/utility/user.go (about)

     1  // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
     2  //
     3  // This software (Documize Community Edition) is licensed under 
     4  // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
     5  //
     6  // You can operate outside the AGPL restrictions by purchasing
     7  // Documize Enterprise Edition and obtaining a commercial license
     8  // by contacting <sales@documize.com>. 
     9  //
    10  // https://documize.com
    11  
    12  package utility
    13  
    14  import (
    15  	"strings"
    16  )
    17  
    18  // MakeInitials returns user initials from firstname and lastname.
    19  func MakeInitials(firstname, lastname string) string {
    20  	firstname = strings.TrimSpace(firstname)
    21  	lastname = strings.TrimSpace(lastname)
    22  	a := ""
    23  	b := ""
    24  
    25  	if len(firstname) > 0 {
    26  		a = firstname[:1]
    27  	}
    28  
    29  	if len(lastname) > 0 {
    30  		b = lastname[:1]
    31  	}
    32  
    33  	return strings.ToUpper(a + b)
    34  }