func isSpecial(r rune) bool {
	return (r < '0' || r > '9') && (r < 'a' || r > 'z') && (r < 'A' || r > 'Z')
}
isSpecial checks if rune is non-alphanumeric
package utill
import (
	"fmt"
	"strings"
	"unicode"
)
var (
	errEmptyServiceName   = formatError{"empty service name"}
	errInvalidFirstRune   = formatError{"leading non-letter in service name"}
	errInvalidProjectRoot = formatError{"project must be initialized inside $GOPATH/src directory or below"}
	errMissingGOPATH      = formatError{"$GOPATH environment variable not set"}
)
func serviceNameHelper(str string) (string, error) {
	if len(str) < 1 {
		return str, errEmptyServiceName
	}
	if first := rune(str[0]); !unicode.IsLetter(first) {
		return str, errInvalidFirstRune
	}
	fields := strings.FieldsFunc(str, isSpecial)
	for i := range fields {
		fields[i] = strings.Title(fields[i])
	}
	return strings.Join(fields, ""), nil
}	
func PackageName(str string) (string, error) {
	formatStr, err := serviceNameHelper(str)
	return strings.ToLower(formatStr), err
}
func ServiceName(str string) (string, error) {
	return serviceNameHelper(str)
}
func DatabaseName(str string) (string, error) {
	if first := rune(str[0]); !unicode.IsLetter(first) {
		return "", errInvalidFirstRune
	}
	fields := strings.FieldsFunc(str, isSpecial)
	return strings.Join(fields, "_"), nil
}
func ServerURL(str string) (string, error) {
	if len(str) < 1 {
		return str, errEmptyServiceName
	}
	fields := strings.FieldsFunc(str, isSpecial)
	url := strings.Join(fields, "-")
	return strings.ToLower(url), nil
}
func ProjectRoot(gopath, workdir string) (string, error) {
	if gopath == "" {
		return "", errMissingGOPATH
	}
	if len(workdir) < len(gopath) {
		return "", errInvalidProjectRoot
	}
	if workdir[:len(gopath)] != gopath {
		return "", errInvalidProjectRoot
	}
	projectpath := workdir[len(gopath):]
	dirs := strings.Split(projectpath, "/")
	if len(dirs) < 2 {
		return "", errInvalidProjectRoot
	}
	return strings.Join(dirs[2:], "/"), nil
}