lileio / lile

Easily generate gRPC services in Go ⚡️
MIT License
1.51k stars 88 forks source link

Fix projectBase() #22

Closed sago35 closed 7 years ago

sago35 commented 7 years ago

On case-insensitive systems such as Windows, projectBase (path) sometimes fails. Specifically, it occurs when GOPATH and absPath do not match. It is better to use filepath.Rel () to absorb the differences by the system.

# GOPATH and absPath do not match (ex `c:\` vs `C:\`)
$GOPATH
    -> c:\Users\xxx\dev
srcPath()
    -> c:\Users\xxx\dev\src\
projectBase(C:\Users\xxx\dev\src\github.com\lileio\xyz4)
    -> C:/Users/xxx/dev/src/github.com/lileio/xyz4
# GOPATH and absPath match
$GOPATH
    -> C:\Users\xxx\dev
srcPath()
    -> C:\Users\xxx\dev\src\
projectBase(C:\Users\xxx\dev\src\github.com\lileio\xyz4)
    -> C:/Users/xxx/dev/src/github.com/lileio/xyz4