On Thu, Mar 18, 2021 at 09:30:44AM +0000, Mikolaj Kucharski wrote:
> Not tested, but does below help?
> 
>                       | grep -qe '^main$$' && \

Yes, this works perfectly.  Thanks!

Updated diff, and also updated the go-module(5) manpage to reflect
this change.

diff 6eaf30816f4def2f40cb2b765a3aa33ae11ae4a8 /home/jrick/ports
blob - 3c137447b5e134aea6cbb3f9ad5d8dccfd27e234
file + lang/go/go.port.mk
--- lang/go/go.port.mk
+++ lang/go/go.port.mk
@@ -52,11 +52,13 @@ MAKE_ENV +=         GOCACHE="${MODGO_GOCACHE}"
 
 MODGO_CMD ?=           ${SETENV} ${MAKE_ENV} go
 MODGO_BUILD_CMD =      ${MODGO_CMD} install ${MODGO_FLAGS}
+MODGO_LIST_CMD =       ${MODGO_CMD} list ${MODGO_FLAGS}
 MODGO_TEST_CMD =       ${MODGO_CMD} test ${MODGO_FLAGS} ${MODGO_TEST_FLAGS}
 MODGO_BINDIR ?=                bin
 
 .if ! empty(MODGO_LDFLAGS)
 MODGO_BUILD_CMD +=     -ldflags="${MODGO_LDFLAGS}"
+MODGO_LIST_CMD +=      -ldflags="${MODGO_LDFLAGS}"
 MODGO_TEST_CMD +=      -ldflags="${MODGO_LDFLAGS}"
 .endif
 
@@ -153,12 +155,13 @@ do-build:
        cd ${WRKSRC} && \
                ${MODGO_BUILD_TARGET}
 .    else
+       cd ${WRKSRC} && \
+               ${MODGO_LIST_CMD} -f '{{.Name}}' ${ALL_TARGET} 2>/dev/null \
+                       | grep -qe '^main$$' && \
+               ${MODGO_BUILD_CMD} ${ALL_TARGET} ; \
        if [ -d ${WRKSRC}/cmd ]; then \
                cd ${WRKSRC} && \
-                       ${MODGO_BUILD_CMD} ${ALL_TARGET}/cmd/... ; \
-       else \
-               cd ${WRKSRC} && \
-                       ${MODGO_BUILD_CMD} ${ALL_TARGET} ; \
+                       ${MODGO_BUILD_CMD} ./cmd/... ; \
        fi;
 .    endif
 .  endif

diff 5dfe4c7116fefdfa88d0ee0df89758e96e280278 /usr/src
blob - fa9ad732b02deea54e376413bd61ebec3051898b
file + share/man/man5/go-module.5
--- share/man/man5/go-module.5
+++ share/man/man5/go-module.5
@@ -135,7 +135,7 @@ are appended to port's
 Defaults to
 .Ar Yes .
 .It Ev MODGO_MODNAME
-is the module name as defined in the
+Name of Go module as defined in the
 .Pa go.mod
 file contained in a project.
 If this is set,
@@ -150,9 +150,7 @@ When
 .Ev MODGO_MODFILES
 is set, and a "cmd" directory is found in
 .Ev WRKSRC ,
-"cmd/..." is appended to
-.Ev ALL_TARGET
-in
+"./cmd/..." is also installed by
 .Cm do-build
 automatically.
 .It Ev MODGO_VERSION

Reply via email to