Skip to content

Commit

Permalink
feat(plc4go): added generic min method
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Nov 10, 2022
1 parent e0a7639 commit 4d8ead9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions plc4go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
github.com/stretchr/testify v1.8.1
github.com/subchen/go-xmldom v1.1.2
github.com/viney-shih/go-lock v1.1.2
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316
golang.org/x/tools v0.2.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
2 changes: 2 additions & 0 deletions plc4go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 h1:FedCSp0+vayF11p3wAQndIgu+JTcW2nLp5M+HSefjlM=
golang.org/x/exp v0.0.0-20221109205753-fc8884afc316/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
13 changes: 12 additions & 1 deletion plc4go/spi/utils/Misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package utils

import "time"
import (
"golang.org/x/exp/constraints"
"time"
)

// InlineIf is basically a inline if like construct for golang
func InlineIf(test bool, a func() interface{}, b func() interface{}) interface{} {
Expand All @@ -40,3 +43,11 @@ func CleanupTimer(timer *time.Timer) {
}
}
}

func Min[T constraints.Ordered](left, right T) T {
if left < right {
return left
} else {
return right
}
}

0 comments on commit 4d8ead9

Please sign in to comment.