Skip to content

Commit

Permalink
Remove ConnectToTcp util
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Apr 16, 2014
1 parent 02e1483 commit 7969fbc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
18 changes: 0 additions & 18 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import (
"io"
"math"
"math/rand"
"net"
"reflect"
"regexp"
"time"
)

type Port io.ReadWriteCloser

func Every(t string, f func()) {
dur := parseDuration(t)
go func() {
Expand Down Expand Up @@ -51,14 +47,6 @@ func Rand(max int) int {
return rand.Intn(max)
}

func ConnectToTcp(port string) io.ReadWriteCloser {
tcpPort, err := net.Dial("tcp", port)
if err != nil {
panic(err)
}
return tcpPort
}

func ConnectToSerial(port string, baud int) io.ReadWriteCloser {
c := &serial.Config{Name: port, Baud: baud}
s, err := serial.OpenPort(c)
Expand All @@ -68,12 +56,6 @@ func ConnectToSerial(port string, baud int) io.ReadWriteCloser {
return s
}

func IsUrl(s string) bool {
ip := regexp.MustCompile("([^A-Za-z0-9]+).([^A-Za-z0-9]+).([^A-Za-z0-9]+)")
url := regexp.MustCompile("([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?")
return ip.MatchString(s) || url.MatchString(s)
}

func Call(thing interface{}, method string, params ...interface{}) []reflect.Value {
in := make([]reflect.Value, len(params))
for k, param := range params {
Expand Down
5 changes: 0 additions & 5 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ var _ = Describe("Utils", func() {
Expect(ToScale(-1, 0, 10)).To(Equal(float64(0)))
Expect(ToScale(0.5, 0, 10)).To(Equal(float64(5)))
})
It("should return true on url or ip address", func() {
Expect(IsUrl("127.0.0.1")).To(Equal(true))
Expect(IsUrl("http://www.google.com")).To(Equal(true))
Expect(IsUrl("/dev/ttyACM0")).To(Equal(false))
})
It("should return random int", func() {
a := Rand(100)
b := Rand(100)
Expand Down

0 comments on commit 7969fbc

Please sign in to comment.