MCPcopy
hub / github.com/go-gorm/gorm / RTrimSlice

Function RTrimSlice

utils/utils.go:192–200  ·  view source on GitHub ↗

RTrimSlice Right trims the given slice by given length

(v []T, trimLen int)

Source from the content-addressed store, hash-verified

190
191// RTrimSlice Right trims the given slice by given length
192func RTrimSlice[T any](v []T, trimLen int) []T {
193 if trimLen >= len(v) { // trimLen greater than slice len means fully sliced
194 return v[:0]
195 }
196 if trimLen < 0 { // negative trimLen is ignored
197 return v[:]
198 }
199 return v[:len(v)-trimLen]
200}

Callers 2

AfterQueryFunction · 0.92
TestRTrimSliceFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRTrimSliceFunction · 0.68