go-hep.org/x/hep@v0.38.1/xrootd/port.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package xrootd // import "go-hep.org/x/hep/xrootd" 6 7 import ( 8 "net" 9 "strconv" 10 ) 11 12 func parseAddr(addr string) string { 13 _, _, err := net.SplitHostPort(addr) 14 if err == nil { 15 return addr 16 } 17 switch err := err.(type) { 18 case *net.AddrError: 19 switch err.Err { 20 case "missing port in address": 21 port, e := net.LookupPort("tcp", "rootd") 22 if e != nil { 23 return addr + ":1094" 24 } 25 return addr + ":" + strconv.Itoa(port) 26 } 27 } 28 return addr 29 }