mirror of
https://github.com/golang/go
synced 2024-11-26 15:27:04 -07:00
4b0b7d8dfe
- almost back to where I was in C++, but now all in Go R=r OCL=13627 CL=13627
30 lines
568 B
Go
30 lines
568 B
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package Utils
|
|
|
|
|
|
export BaseName
|
|
func BaseName(s string) string {
|
|
// TODO this is not correct for non-ASCII strings!
|
|
i := len(s) - 1;
|
|
for i >= 0 && s[i] != '/' {
|
|
if s[i] > 128 {
|
|
panic "non-ASCII string"
|
|
}
|
|
i--;
|
|
}
|
|
return s[i + 1 : len(s)];
|
|
}
|
|
|
|
|
|
export FixExt
|
|
func FixExt(s string) string {
|
|
i := len(s) - 3; // 3 == len(".go");
|
|
if s[i : len(s)] == ".go" {
|
|
s = s[0 : i];
|
|
}
|
|
return s + ".7";
|
|
}
|