]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/common.go
Stylistical change
[govpn.git] / src / cypherpunks.ru / govpn / common.go
index 3fe31651baaeecce97feac2ca017aa70f34e9524..72873d05f17e716f4064315979dcf7b6ce475727 100644 (file)
@@ -121,8 +121,10 @@ func (p *Protocol) UnmarshalYAML(unmarshal func(interface{}) error) error {
 
 // NewProtocolFromString converts a string into a govpn.Protocol
 func NewProtocolFromString(p string) (Protocol, error) {
+       var k Protocol
+       var v string
        lowP := strings.ToLower(p)
-       for k, v := range protocolText {
+       for k, v = range protocolText {
                if strings.ToLower(v) == lowP {
                        return k, nil
                }
@@ -130,17 +132,14 @@ func NewProtocolFromString(p string) (Protocol, error) {
 
        choices := make([]string, len(protocolText))
        var index = 0
-       for k, v := range protocolText {
-               if v == p {
-                       z := k
-                       p = &z
-                       return nil
-               }
-               choices[index] = v
+       for k = range protocolText {
+               choices[index] = protocolText[k]
                index++
        }
 
-       return Protocol(-1), errors.Errorf("Invalid protocol %q: %s", p, strings.Join(choices, ","))
+       return Protocol(-1), errors.Errorf(
+               "Invalid protocol %q: %s", p, strings.Join(choices, ","),
+       )
 }
 
 // SliceZero zeros each byte.