➜ hugo git:(add-youtube-shortcode-start-offset) ✗ which go
/usr/local/go/bin/go
➜ hugo git:(add-youtube-shortcode-start-offset) ✗ go version
go version go1.19.4 darwin/amd64
➜ hugo git:(add-youtube-shortcode-start-offset) ✗ go clean --modcache
I tried the same install chant after this, same error. Thanks for the suggestion though!
II would say that after Go Modules was introduced, building Hugo from source has mostly been simple.
I see 2 things to try:
While go install ... github.com/... should work, if you want to modify a shortcode in the Hugo source, I suspect the easies way is to start with cloning the repo:
git clone https://github.com/gohugoio/hugo.git
cd hugo
go build
Also, the -tags extended code is just needed to build a small part of Hugo and to get started (and it complicates the build setup as you need a C/C++ compiler installed). I would just run go build, go test. etc. without any additional flags.
You definitely got me around this. Thanks! I have a PR i want to get through and I want to write a test to prove the code. The only thing I don’t quite get is with a fresh clone of the hugo source, if I cd in and run the test suite, it says there aren’t any tests? What am I missing here?
➜ h git:(master) git log |head -1
commit 17055d1fa76ca23a408a2e6d4d67cc8023f4d2ed
➜ h git:(master) go build
➜ h git:(master) ls -l $GOPATH/bin/hugo
-rwxr-xr-x 1 stevenharms staff 82524776 Dec 14 15:41 /Users/stevenharms/go/bin/hugo
➜ h git:(master) go test
? github.com/gohugoio/hugo [no test files]
➜ h git:(master)
Your list here should really form the basis of CONTRIBUTING.md! While I can edit templates and HTML, the golang toolchain and its attendant env vars make casual contribution onerous. Your summary is very helpful.
For me it’s steps 7-9 in your list that are troublesome
➜ h git:(null-featureadd) ✗ go install -tags extended
# github.com/bep/golibsass/internal/libsass
In file included from json.cpp:2:
../../go/pkg/mod/github.com/bep/golibsass@v1.1.0/internal/libsass/../../libsass_src/src/json.cpp:1289:3: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
Chatty, but no error status. Continuing:
$ $GOPATH/bin/mage -v test 2>&1 |tee log
$ cat log
Running target: Test
exec: go "test" "./..." "-tags" "none"
? github.com/gohugoio/hugo [no test files]
ok github.com/gohugoio/hugo/bufferpool (cached)
ok github.com/gohugoio/hugo/cache/filecache (cached)
ok github.com/gohugoio/hugo/cache/namedmemcache (cached)
--- FAIL: TestMethods (0.00s)
--- FAIL: TestMethods/MethodsFromTypes (0.00s)
panic: dir must be set to the Hugo root [recovered]
panic: dir must be set to the Hugo root
...
...[SNIP]
AFAICT, I’m in the hugo root. In the same dir as main.go. If I can get these tools running, I promise I can get steps 10-12 on my own. I do it all day every day.
Addendum
I went back to the build steps suggested in CONTRIBUTING.md and found that the preferred test path is to run mage -v check. That also hit the same hugo root error as above.