// Copyright 2020 The Gogs Authors. All rights reserved.// Use of this source code is governed by a MIT-style// license that can be found in the LICENSE file.packagestrutilimport("crypto/rand""math/big""unicode")// ToUpperFirst returns s with only the first Unicode letter mapped to its upper case.funcToUpperFirst(sstring)string{fori,v:=ranges{returnstring(unicode.ToUpper(v))+s[i+1:]}return""}// RandomChars returns a generated string in given number of random characters.funcRandomChars(nint)(string,error){constalphanum="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"randomInt:=func(max*big.Int)(int,error){r,err:=rand.Int(rand.Reader,max)iferr!=nil{return0,err}returnint(r.Int64()),nil}buffer:=make([]byte,n)max:=big.NewInt(int64(len(alphanum)))fori:=0;i<n;i++{index,err:=randomInt(max)iferr!=nil{return"",err}buffer[i]=alphanum[index]}returnstring(buffer),nil}