Check type of Git url protocol simply whether is SSH, HTTP or HTTPS with Zero Dependencies
type Type struct {
Address string
Type string
RepositoryName string
}
go get -u -v github.com/supanadit/gity
import "github.com/supanadit/gity"
gity, err := gity.Check("git@github.com:supanadit/jwt-go.git")
if err != nil {
panic(err)
}
fmt.Println(gity.IsHTTPORS()) // false
fmt.Println(gity.IsHTTP()) // false
fmt.Println(gity.IsHTTPS()) // false
fmt.Println(gity.IsSSH()) // true
type, err := gity.Check("https://github.com/supanadit/jwt-go.git")
if err != nil {
panic(err)
}
fmt.Println(type.IsHTTPORS()) // true
fmt.Println(type.IsHTTP()) // false
fmt.Println(type.IsHTTPS()) // true
fmt.Println(type.IsSSH()) // false