github.com/blend/go-sdk@v1.20220411.3/stringutil/trimlen.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package stringutil
     9  
    10  // TrimLen trims a string to a given length, i.e. the substring [0, length).
    11  func TrimLen(val string, length int) string {
    12  	if len(val) > length {
    13  		return val[0:length]
    14  	}
    15  	return val
    16  }