Skip to content

Commit b13bdad

Browse files
committed
Run update.sh
1 parent 9047db4 commit b13bdad

File tree

5 files changed

+105
-75
lines changed

5 files changed

+105
-75
lines changed

1.2/go-wrapper

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ usage: $base command [args]
1010
This script assumes that is is run from the root of your Go package (for
1111
example, "/go/src/app" if your GOPATH is set to "/go").
1212
13-
The main feature of this wrapper over the native "go" tool is that it supports
14-
the addition of a ".godir" file in your package directory which is a plain text
15-
file that is the import path your application expects (ie, it would be something
16-
like "github.com/jsmith/my-cool-app"). If this file is found, the current
17-
package is then symlinked to /go/src/<.gopath> and the commands then use that
18-
full import path to act on it. This allows for applications to be universally
19-
cloned into a path like "/go/src/app" and then automatically built properly so
20-
that inter-package imports use the existing source instead of downloading it a
21-
second time. This also makes the final binary have the correct name (ie,
22-
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
23-
the "run" command exists here.
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
2426
2527
Available Commands:
2628
@@ -46,12 +48,14 @@ if ! shift; then
4648
exit 1
4749
fi
4850

49-
dir="$(pwd -P)"
50-
goBin="$(basename "$dir")" # likely "app"
51+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
5152

52-
goDir=
53-
if [ -f .godir ]; then
53+
if [ -z "$goDir" -a -s .godir ]; then
5454
goDir="$(cat .godir)"
55+
fi
56+
57+
dir="$(pwd -P)"
58+
if [ "$goDir" ]; then
5559
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
5660
goDirPath="$goPath/src/$goDir"
5761
mkdir -p "$(dirname "$goDirPath")"
@@ -62,6 +66,8 @@ if [ -f .godir ]; then
6266
exit 1
6367
fi
6468
goBin="$goPath/bin/$(basename "$goDir")"
69+
else
70+
goBin="$(basename "$dir")" # likely "app"
6571
fi
6672

6773
case "$cmd" in

1.3/go-wrapper

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ usage: $base command [args]
1010
This script assumes that is is run from the root of your Go package (for
1111
example, "/go/src/app" if your GOPATH is set to "/go").
1212
13-
The main feature of this wrapper over the native "go" tool is that it supports
14-
the addition of a ".godir" file in your package directory which is a plain text
15-
file that is the import path your application expects (ie, it would be something
16-
like "github.com/jsmith/my-cool-app"). If this file is found, the current
17-
package is then symlinked to /go/src/<.gopath> and the commands then use that
18-
full import path to act on it. This allows for applications to be universally
19-
cloned into a path like "/go/src/app" and then automatically built properly so
20-
that inter-package imports use the existing source instead of downloading it a
21-
second time. This also makes the final binary have the correct name (ie,
22-
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
23-
the "run" command exists here.
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
2426
2527
Available Commands:
2628
@@ -46,12 +48,14 @@ if ! shift; then
4648
exit 1
4749
fi
4850

49-
dir="$(pwd -P)"
50-
goBin="$(basename "$dir")" # likely "app"
51+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
5152

52-
goDir=
53-
if [ -f .godir ]; then
53+
if [ -z "$goDir" -a -s .godir ]; then
5454
goDir="$(cat .godir)"
55+
fi
56+
57+
dir="$(pwd -P)"
58+
if [ "$goDir" ]; then
5559
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
5660
goDirPath="$goPath/src/$goDir"
5761
mkdir -p "$(dirname "$goDirPath")"
@@ -62,6 +66,8 @@ if [ -f .godir ]; then
6266
exit 1
6367
fi
6468
goBin="$goPath/bin/$(basename "$goDir")"
69+
else
70+
goBin="$(basename "$dir")" # likely "app"
6571
fi
6672

6773
case "$cmd" in

1.3/wheezy/go-wrapper

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ usage: $base command [args]
1010
This script assumes that is is run from the root of your Go package (for
1111
example, "/go/src/app" if your GOPATH is set to "/go").
1212
13-
The main feature of this wrapper over the native "go" tool is that it supports
14-
the addition of a ".godir" file in your package directory which is a plain text
15-
file that is the import path your application expects (ie, it would be something
16-
like "github.com/jsmith/my-cool-app"). If this file is found, the current
17-
package is then symlinked to /go/src/<.gopath> and the commands then use that
18-
full import path to act on it. This allows for applications to be universally
19-
cloned into a path like "/go/src/app" and then automatically built properly so
20-
that inter-package imports use the existing source instead of downloading it a
21-
second time. This also makes the final binary have the correct name (ie,
22-
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
23-
the "run" command exists here.
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
2426
2527
Available Commands:
2628
@@ -46,12 +48,14 @@ if ! shift; then
4648
exit 1
4749
fi
4850

49-
dir="$(pwd -P)"
50-
goBin="$(basename "$dir")" # likely "app"
51+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
5152

52-
goDir=
53-
if [ -f .godir ]; then
53+
if [ -z "$goDir" -a -s .godir ]; then
5454
goDir="$(cat .godir)"
55+
fi
56+
57+
dir="$(pwd -P)"
58+
if [ "$goDir" ]; then
5559
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
5660
goDirPath="$goPath/src/$goDir"
5761
mkdir -p "$(dirname "$goDirPath")"
@@ -62,6 +66,8 @@ if [ -f .godir ]; then
6266
exit 1
6367
fi
6468
goBin="$goPath/bin/$(basename "$goDir")"
69+
else
70+
goBin="$(basename "$dir")" # likely "app"
6571
fi
6672

6773
case "$cmd" in

1.4/go-wrapper

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ usage: $base command [args]
1010
This script assumes that is is run from the root of your Go package (for
1111
example, "/go/src/app" if your GOPATH is set to "/go").
1212
13-
The main feature of this wrapper over the native "go" tool is that it supports
14-
the addition of a ".godir" file in your package directory which is a plain text
15-
file that is the import path your application expects (ie, it would be something
16-
like "github.com/jsmith/my-cool-app"). If this file is found, the current
17-
package is then symlinked to /go/src/<.gopath> and the commands then use that
18-
full import path to act on it. This allows for applications to be universally
19-
cloned into a path like "/go/src/app" and then automatically built properly so
20-
that inter-package imports use the existing source instead of downloading it a
21-
second time. This also makes the final binary have the correct name (ie,
22-
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
23-
the "run" command exists here.
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
2426
2527
Available Commands:
2628
@@ -46,12 +48,14 @@ if ! shift; then
4648
exit 1
4749
fi
4850

49-
dir="$(pwd -P)"
50-
goBin="$(basename "$dir")" # likely "app"
51+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
5152

52-
goDir=
53-
if [ -f .godir ]; then
53+
if [ -z "$goDir" -a -s .godir ]; then
5454
goDir="$(cat .godir)"
55+
fi
56+
57+
dir="$(pwd -P)"
58+
if [ "$goDir" ]; then
5559
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
5660
goDirPath="$goPath/src/$goDir"
5761
mkdir -p "$(dirname "$goDirPath")"
@@ -62,6 +66,8 @@ if [ -f .godir ]; then
6266
exit 1
6367
fi
6468
goBin="$goPath/bin/$(basename "$goDir")"
69+
else
70+
goBin="$(basename "$dir")" # likely "app"
6571
fi
6672

6773
case "$cmd" in

1.4/wheezy/go-wrapper

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ usage: $base command [args]
1010
This script assumes that is is run from the root of your Go package (for
1111
example, "/go/src/app" if your GOPATH is set to "/go").
1212
13-
The main feature of this wrapper over the native "go" tool is that it supports
14-
the addition of a ".godir" file in your package directory which is a plain text
15-
file that is the import path your application expects (ie, it would be something
16-
like "github.com/jsmith/my-cool-app"). If this file is found, the current
17-
package is then symlinked to /go/src/<.gopath> and the commands then use that
18-
full import path to act on it. This allows for applications to be universally
19-
cloned into a path like "/go/src/app" and then automatically built properly so
20-
that inter-package imports use the existing source instead of downloading it a
21-
second time. This also makes the final binary have the correct name (ie,
22-
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
23-
the "run" command exists here.
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
2426
2527
Available Commands:
2628
@@ -46,12 +48,14 @@ if ! shift; then
4648
exit 1
4749
fi
4850

49-
dir="$(pwd -P)"
50-
goBin="$(basename "$dir")" # likely "app"
51+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
5152

52-
goDir=
53-
if [ -f .godir ]; then
53+
if [ -z "$goDir" -a -s .godir ]; then
5454
goDir="$(cat .godir)"
55+
fi
56+
57+
dir="$(pwd -P)"
58+
if [ "$goDir" ]; then
5559
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
5660
goDirPath="$goPath/src/$goDir"
5761
mkdir -p "$(dirname "$goDirPath")"
@@ -62,6 +66,8 @@ if [ -f .godir ]; then
6266
exit 1
6367
fi
6468
goBin="$goPath/bin/$(basename "$goDir")"
69+
else
70+
goBin="$(basename "$dir")" # likely "app"
6571
fi
6672

6773
case "$cmd" in

0 commit comments

Comments
 (0)