Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
m-team
oidc
mytoken
server
Commits
b3c7a9eb
Commit
b3c7a9eb
authored
3 years ago
by
Gabriel Zachmann
Browse files
Options
Downloads
Patches
Plain Diff
add ternary util
parent
a13e9c8f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/utils/ternary/ternary.go
+17
-0
17 additions, 0 deletions
shared/utils/ternary/ternary.go
with
17 additions
and
0 deletions
shared/utils/ternary/ternary.go
0 → 100644
+
17
−
0
View file @
b3c7a9eb
package
ternary
// IfNotEmptyOr returns a if not empty, otherwise b
func
IfNotEmptyOr
(
a
,
b
string
)
string
{
if
a
!=
""
{
return
a
}
return
b
}
// If returns a if con is true, b otherwise
func
If
(
con
bool
,
a
,
b
interface
{})
interface
{}
{
if
con
{
return
a
}
return
b
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment