Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
398039b3
Commit
398039b3
authored
Oct 06, 2018
by
Christian Schlotter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix golint errors in pkg/util/strings
Signed-off-by:
Christian Schlotter
<
christi.schlotter@gmail.com
>
parent
664d7972
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
10 deletions
+8
-10
.golint_failures
hack/.golint_failures
+0
-1
strings.go
pkg/util/strings/strings.go
+4
-5
strings_test.go
pkg/util/strings/strings_test.go
+4
-4
No files found.
hack/.golint_failures
View file @
398039b3
...
@@ -372,7 +372,6 @@ pkg/util/removeall
...
@@ -372,7 +372,6 @@ pkg/util/removeall
pkg/util/resourcecontainer
pkg/util/resourcecontainer
pkg/util/rlimit
pkg/util/rlimit
pkg/util/selinux
pkg/util/selinux
pkg/util/strings
pkg/util/sysctl
pkg/util/sysctl
pkg/util/sysctl/testing
pkg/util/sysctl/testing
pkg/util/system
pkg/util/system
...
...
pkg/util/strings/strings.go
View file @
398039b3
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"unicode"
"unicode"
)
)
// Splits a fully qualified name and returns its namespace and name.
// Split
QualifiedName Split
s a fully qualified name and returns its namespace and name.
// Assumes that the input 'str' has been validated.
// Assumes that the input 'str' has been validated.
func
SplitQualifiedName
(
str
string
)
(
string
,
string
)
{
func
SplitQualifiedName
(
str
string
)
(
string
,
string
)
{
parts
:=
strings
.
Split
(
str
,
"/"
)
parts
:=
strings
.
Split
(
str
,
"/"
)
...
@@ -32,19 +32,18 @@ func SplitQualifiedName(str string) (string, string) {
...
@@ -32,19 +32,18 @@ func SplitQualifiedName(str string) (string, string) {
return
parts
[
0
],
parts
[
1
]
return
parts
[
0
],
parts
[
1
]
}
}
// Joins 'namespace' and 'name' and returns a fully qualified name
// Join
QualifiedName join
s 'namespace' and 'name' and returns a fully qualified name
// Assumes that the input is valid.
// Assumes that the input is valid.
func
JoinQualifiedName
(
namespace
,
name
string
)
string
{
func
JoinQualifiedName
(
namespace
,
name
string
)
string
{
return
path
.
Join
(
namespace
,
name
)
return
path
.
Join
(
namespace
,
name
)
}
}
//
R
eturns the first N slice of a string.
//
ShortenString r
eturns the first N slice of a string.
func
ShortenString
(
str
string
,
n
int
)
string
{
func
ShortenString
(
str
string
,
n
int
)
string
{
if
len
(
str
)
<=
n
{
if
len
(
str
)
<=
n
{
return
str
return
str
}
else
{
return
str
[
:
n
]
}
}
return
str
[
:
n
]
}
}
// isVowel returns true if the rune is a vowel (case insensitive).
// isVowel returns true if the rune is a vowel (case insensitive).
...
...
pkg/util/strings/strings_test.go
View file @
398039b3
...
@@ -56,16 +56,16 @@ func TestJoinQualifiedName(t *testing.T) {
...
@@ -56,16 +56,16 @@ func TestJoinQualifiedName(t *testing.T) {
func
TestShortenString
(
t
*
testing
.
T
)
{
func
TestShortenString
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
input
string
input
string
out
_l
en
int
out
L
en
int
output
string
output
string
}{
}{
{
"kubernetes.io"
,
5
,
"kuber"
},
{
"kubernetes.io"
,
5
,
"kuber"
},
{
"blah"
,
34
,
"blah"
},
{
"blah"
,
34
,
"blah"
},
{
"kubernetes.io"
,
13
,
"kubernetes.io"
},
{
"kubernetes.io"
,
13
,
"kubernetes.io"
},
}
}
for
i
,
tc
:=
range
testCases
{
for
i
,
tc
:=
range
testCases
{
res
:=
ShortenString
(
tc
.
input
,
tc
.
out
_l
en
)
res
:=
ShortenString
(
tc
.
input
,
tc
.
out
L
en
)
if
res
!=
tc
.
output
{
if
res
!=
tc
.
output
{
t
.
Errorf
(
"case[%d]: expected %q, got %q"
,
i
,
tc
.
output
,
res
)
t
.
Errorf
(
"case[%d]: expected %q, got %q"
,
i
,
tc
.
output
,
res
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment