* Go build system - build from local directory fails
@ 2024-12-18 11:01 Marc
2024-12-22 6:12 ` Marek Paśnikowski
0 siblings, 1 reply; 3+ messages in thread
From: Marc @ 2024-12-18 11:01 UTC (permalink / raw)
To: help-guix
Hey,
I'm trying to build a go program that is located locally, and figured
I'd use to go-build-system to do so. I've created the following
(use-modules (guix gexp)
(guix packages)
(gnu packages gcc)
(gnu packages golang)
(guix build-system go)
(guix git-download)
(guix utils)
(guix download)
(guix build-system go)
(gnu packages bash))
(define (vcs-file? file stat)
"Return #t if file is a version-controlled file."
(case (stat:type stat)
((directory)
(member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
((regular)
;; Git sub-modules have a '.git' file that is a regular text file.
(string=? (basename file) ".git"))
(else
#f)))
(define %script-name "my-project")
(package
(name %script-name)
(version "0.1")
(source (local-file "." %script-name
#:recursive? #t
#:select? vcs-file?))
(build-system go-build-system)
(home-page #f)
(synopsis "")
(description "")
(license #f))
Which I attempted to invoke with ~guix build -f myfile.scm~ but I get
errors. The program builds without issue otherwise, but here I get the error:
command "go" "install" "-v" "-x" "-ldflags=-s -w" "-trimpath" "" failed with status 1
An initial suspicion is that I haven't set ‘#:import-path’ as expected
in the documentation. However, all examples I can find of this are
builds from a github repository rather than a local file, so I am not
sure what it needs to be set to.
Any clue what I could be missing?
Cheers,
--
Marc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Go build system - build from local directory fails
2024-12-18 11:01 Go build system - build from local directory fails Marc
@ 2024-12-22 6:12 ` Marek Paśnikowski
2024-12-23 20:44 ` Leo Famulari
0 siblings, 1 reply; 3+ messages in thread
From: Marek Paśnikowski @ 2024-12-22 6:12 UTC (permalink / raw)
To: help-guix
> An initial suspicion is that I haven't set ‘#:import-path’ as expected
> in the documentation. However, all examples I can find of this are
> builds from a github repository rather than a local file, so I am not
> sure what it needs to be set to.
>
> Any clue what I could be missing?
This is exactly it. You always must supply the #:import-path in Go build
system.
This path is vital to the operation of the build system, as it adapts Go build
environment to Guix environment. This path matches the name of the currently
built module.
In practice, it is the string that follows the 'module' keyword in go.mod
files.
I do not know the theory behind this coupling.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Go build system - build from local directory fails
2024-12-22 6:12 ` Marek Paśnikowski
@ 2024-12-23 20:44 ` Leo Famulari
0 siblings, 0 replies; 3+ messages in thread
From: Leo Famulari @ 2024-12-23 20:44 UTC (permalink / raw)
To: Marek Paśnikowski, znavko--- via
On Sun, Dec 22, 2024, at 01:12, Marek Paśnikowski wrote:
> This is exactly it. You always must supply the #:import-path in Go build
> system.
>
> This path is vital to the operation of the build system, as it adapts Go build
> environment to Guix environment. This path matches the name of the currently
> built module.
>
> In practice, it is the string that follows the 'module' keyword in go.mod
> files.
>
> I do not know the theory behind this coupling.
There is not much theory behind it.
At the time we made the go-build-system, the process of building Go packages was different from how it is today. For example, Go modules had not been invented yet.
Additionally, those of us who made the go-build-system were not Go programmers and did not (and still do not) have a strong understanding of how Go software is built.
But, the import path was critical for building a Go codebase at that time. It was (is?) the actual "name" of the software, and is generally equivalent to the canonical URI from where the code is fetched. An unusual choice but it was the choice made by the Go team.
Overall, Guix's Go build system is due for a complete overhaul by people who actually understand Go idioms.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-23 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 11:01 Go build system - build from local directory fails Marc
2024-12-22 6:12 ` Marek Paśnikowski
2024-12-23 20:44 ` Leo Famulari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).