kubernetes/gengo · namer.go
go logo
func (ns *NameStrategy) removePrefixAndSuffix(s string) string {
	// The join function may have changed capitalization.
	lowerIn := strings.ToLower(s)
	lowerP := strings.ToLower(ns.Prefix)
	lowerS := strings.ToLower(ns.Suffix)
	b, e := 0, len(s)
	if strings.HasPrefix(lowerIn, lowerP) {
		b = len(ns.Prefix)
	}
	if strings.HasSuffix(lowerIn, lowerS) {
		e -= len(ns.Suffix)
	}
	return s[b:e]
}
Similar code snippets
1.
brutella/hc · characteristic.go
Match rating: 55.24% · See similar code snippets
go logo
func underscored(s string) string {
	lowered := strings.ToLower(strip(s))
	return strings.Replace(lowered, " ", "_", -1)
}
2.
gorgonia/cu · parse.go
Match rating: 53.83% · See similar code snippets
go logo
func processEnumName(lcp, name string) string {
	// special cornercases names
	switch name {
	case "CUDNN_32BIT_INDICES":
		return "Indices32"
	case "CUDNN_64BIT_INDICES":
		return "Indices64"
	case "CUDNN_16BIT_INDICES":
		return "Indices16"
	case "CUDNN_8BIT_INDICES":
		return "Indices8"
	case "CUDNN_POOLING_MAX":
		return "MaxPooling"
	case "CUDNN_LRN_CROSS_CHANNEL_DIM1":
		return "CrossChannelDim1"
	case "CUDNN_DIVNORM_PRECOMPUTED_MEANS":
		return "PrecomputedMeans"
	case "CUDNN_SAMPLER_BILINEAR":
		return "Bilinear"
	}

	var trimmed string
	if len(lcp) < 9 && len(lcp) > 6 { // CUDNN_ or CUDNN_XXX
		lcp = "CUDNN_"
	}
	trimmed = strings.TrimPrefix(name, lcp)
	lowered := strings.ToLower(trimmed)

	switch lcp {
	case "CUDNN_TENSOR_N":
		// tensor description
		lowered = "n" + lowered
		upper := strings.ToUpper(lowered[:4])
		lowered = upper + lowered[4:]
	case "CUDNN_REDUCE_TENSOR_":
		// reduction op
		lowered = "Reduce_" + lowered
	case "CUDNN_CTC_LOSS_ALGO_":
		// CTC Loss Algorithms
		lowered = lowered + "CTCLoss"
	default:
	}

	retVal := bindgen.Snake2Camel(lowered, true)

	// final cleanup
	switch retVal {
	case "Relu":
		return "ReLU"
	case "ClippedRelu":
		return "ClippedReLU"
	case "RnnRelu":
		return "RNNReLU"
	case "RnnTanh":
		return "RNNTanh"
	case "Lstm":
		return "LSTM"
	case "Gru":
		return "GRU"
	}
	return retVal
}
3.
keybase/client · simplefs_ls.go
Match rating: 53.11% · See similar code snippets
go logo
func (listings Listings) lessByName(i, j int) bool {
	a := listings[i]
	b := listings[j]
	aNameLower := strings.ToLower(a.name)
	bNameLower := strings.ToLower(b.name)

	if aNameLower != bNameLower {
		return aNameLower < bNameLower
	}
	// If capitalization is the only thing different between the
	// words, put lower-case first.
	return a.name >= b.name
}
4.
nerdzeu/nerdz-api · user.go
Match rating: 52.65% · See similar code snippets
go logo
func (user *User) NumericFollowers() (followers []uint64) {
	Db().Model(UserFollower{}).Where(UserFollower{To: user.ID()}).Pluck(`"from"`, &followers)
	return
}
5.
luci/luci-go · transform.go
Match rating: 52.43% · See similar code snippets
go logo
func firstLower(s string) string {
	_, w := utf8.DecodeRuneInString(s)
	return strings.ToLower(s[:w]) + s[w:]
}
6.
nerdzeu/nerdz-api · project.go
Match rating: 52.41% · See similar code snippets
go logo
func (prj *Project) NumericFollowers() (followers []uint64) {
	Db().Model(ProjectFollower{}).Where(ProjectFollower{To: prj.ID()}).Pluck(`"from"`, &followers)
	return
}
7.
syncthing/syncthing · basicfs_windows.go
Match rating: 52.02% · See similar code snippets
go logo
func rel(path, prefix string) string {
	lowerRel := strings.TrimPrefix(strings.TrimPrefix(UnicodeLowercase(path), UnicodeLowercase(prefix)), string(PathSeparator))
	return path[len(path)-len(lowerRel):]
}
8.
nildev/lib · types.go
Match rating: 51.39% · See similar code snippets
go logo
func makeFirstLowerCase(s string) string {
	a := []rune(s)
	a[0] = unicode.ToLower(a[0])
	return string(a)
}
9.
etcd-io/etcd · leader.go
Match rating: 51.06% · See similar code snippets
go logo
func (ls *LeaderStats) Follower(name string) *FollowerStats {
	ls.Lock()
	defer ls.Unlock()
	fs, ok := ls.Followers[name]
	if !ok {
		fs = &FollowerStats{}
		fs.Latency.Minimum = 1 << 63
		ls.Followers[name] = fs
	}
	return fs
}
10.
aws/amazon-ecs-agent · task_windows.go
Match rating: 50.99% · See similar code snippets
go logo
func getCanonicalPath(path string) string {
	lowercasedPath := strings.ToLower(path)
	// if the path is a bare drive like "d:", don't filepath.Clean it because it will add a '.'.
	// this is to fix the case where mounting from D:\ to D: is supported by docker but not ecs
	if isBareDrive(lowercasedPath) {
		return lowercasedPath
	}

	return filepath.Clean(lowercasedPath)
}