Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2021 19:59
Show Gist options
  • Save marcellmars/97c63010a6448548b985396be394fde3 to your computer and use it in GitHub Desktop.
Save marcellmars/97c63010a6448548b985396be394fde3 to your computer and use it in GitHub Desktop.
hugo tests
package main
import (
func main() {
aFs := afero.NewBasePathFs(afero.NewOsFs(), "/tmp/barfoo")
cfg, err := config.FromFile(aFs, "config.toml")
if err != nil {
osFs := hugofs.Os
cfg.Set("workingDir", "/tmp/barfoo")
l := langs.NewDefaultLanguage(cfg)
cfg.Set("languagesSorted", langs.NewLanguages(l))
fs := hugofs.NewFrom(osFs, cfg)
fmt.Printf("fs: %#v\n", fs)
dd := &deps.DepsCfg{}
dd.Fs = fs
fmt.Printf("dd.Fs: %#v\n", *dd.Fs)
dd.Cfg = cfg
sites, err := hugolib.NewHugoSites(*dd)
if err != nil {
log.Fatal("Could not load Hugo site(s)", err)
_ = sites
hh := hugolib.BuildCfg{SkipRender: true}
err = sites.Build(hh)
if err != nil {
log.Fatal("Could not run render", err)
// for _, p := range sites.Pages() {
// fmt.Println(p)
// }
Copy link

fs: &hugofs.Fs{Source:(*afero.OsFs)(0x222af60), Destination:(*afero.OsFs)(0x222af60), Os:(*afero.OsFs)(0x222b3e8), WorkingDir:(*afero.BasePathFs)(0xc0004e6dc0)}
dd.Fs: hugofs.Fs{Source:(*afero.OsFs)(0x222af60), Destination:(*afero.OsFs)(0x222af60), Os:(*afero.OsFs)(0x222b3e8), WorkingDir:(*afero.BasePathFs)(0xc0004e6dc0)}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x76052f]

goroutine 1 [running]:*BasePathFs).LstatIfPossible(0xc0004e7c00, 0xc000794a60, 0x7, 0x7f8af4766f58, 0xc0004e7c00, 0x147ab01, 0x5, 0x8)
	/home/m/go/pkg/mod/ +0x1cf, 0xc0004e7c00, 0x0, 0x0, 0x8, 0x203000, 0x8, 0x203000, 0x7f8b1d427f18)
	/home/m/go/pkg/mod/ +0x74*FilterFs).LstatIfPossible(0xc0004e7c20, 0x0, 0x0, 0x10, 0x1355c40, 0xc0007db060, 0x0, 0x7f8af475e768)
	/home/m/go/pkg/mod/ +0x66*FilterFs).Stat(0xc0004e7c20, 0x0, 0x0, 0x10, 0xc000000180, 0xe5dbc6, 0xc0006d5440)
	/home/m/go/pkg/mod/ +0x3f*pagesCollector).collectDir(0xc0007e42a0, 0x0, 0x0, 0x1a0bb00, 0x0, 0x7f8af6b15fff, 0x400)
	/home/m/go/pkg/mod/ +0x66*pagesCollector).Collect(0xc0007e42a0, 0x0, 0x0)
	/home/m/go/pkg/mod/ +0x639*Site).readAndProcessContent(0xc0000b66c0, 0x0, 0x0, 0x0, 0x12c5520, 0x1)
	/home/m/go/pkg/mod/ +0x185*Site).process(0xc0000b66c0, 0x0, 0x0, 0x0, 0x1, 0xc0007dad40, 0x0, 0x0, 0x0, 0x1, ...)
	/home/m/go/pkg/mod/ +0x65*HugoSites).process(0xc0004c2000, 0xc0007d9600, 0xc0006d5ab0, 0x0, 0x0, 0x0, 0x222b3e8, 0x11cf701)
	/home/m/go/pkg/mod/ +0x129*HugoSites).Build.func3.2()
	/home/m/go/pkg/mod/ +0x65
runtime/trace.WithRegion(0x1a0bbe0, 0xc0007e80f0, 0x148794a, 0x7, 0xc0006d5ad8)
	/home/m/sdk/go1.16/src/runtime/trace/annotation.go:141 +0xf8*HugoSites).Build.func3(0x222b3e8, 0x1)
	/home/m/go/pkg/mod/ +0x165*HugoSites).Build.func4()
	/home/m/go/pkg/mod/ +0x2f
runtime/trace.WithRegion(0x1a0bbe0, 0xc0007e80f0, 0x14878e1, 0x7, 0xc0006d5c98)
	/home/m/sdk/go1.16/src/runtime/trace/annotation.go:141 +0xf8*HugoSites).Build(0xc0004c2000, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/m/go/pkg/mod/ +0xa57
	/home/m/devel/mygodev/hugo_fs/main.go:39 +0x54e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment