From 7969fbcbeafe1e495c1267cfdcb840d53b9815ca Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Wed, 16 Apr 2014 12:38:09 -0700 Subject: [PATCH] Remove ConnectToTcp util --- utils.go | 18 ------------------ utils_test.go | 5 ----- 2 files changed, 23 deletions(-) diff --git a/utils.go b/utils.go index d0f305b1..2fd8711c 100644 --- a/utils.go +++ b/utils.go @@ -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() { @@ -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) @@ -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 { diff --git a/utils_test.go b/utils_test.go index 0c37e938..a3eb3b04 100644 --- a/utils_test.go +++ b/utils_test.go @@ -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)