Can't intersect 2 slices (even if the same) : intersect does not support slices or arrays of uncomparable types

Hello,

I’m trying to use intersect on 2 slice.
I get intersect does not support slices or arrays of uncomparable types.

So while debugging I reduct my code to the minimum & try intersect 2 identical slice with the same error.
Is this expected behaviour ? The 2 slices are identical by construction.

I really can’t see what I’m doing wrong.
Hugo v0.76.5

This code produce the error.

{{- $v_internal := where .Site.Params.plugins.css "external" false }}
{{ $slice1 := $v_internal }}
{{ $slice2 := $v_internal }}
{{ $slice := intersect $slice1 $slice2 }}

This is $v_internal detail

v_internal : {{ $v_internal }}
Map : {{ reflect.IsMap $v_internal }}
Slice : {{ reflect.IsSlice $v_internal }}
{{ range $v_internal }}
. : {{ . }}
.link : {{ .link }}
{{ end }}

produce this :

v_internal : [map[external:false link:plugins/bootstrap/bootstrap.min.css purge:true] map[external:false link:plugins/slick/slick.css purge:false] map[external:false link:plugins/font-awesome/font-awesome.min.css purge:false] map[external:false link:plugins/venobox/venobox.css purge:false] map[external:false link:plugins/aos/aos.css purge:false]]

Map : false

Slice : true

. : map[external:false link:plugins/bootstrap/bootstrap.min.css purge:true]
.link : plugins/bootstrap/bootstrap.min.css

. : map[external:false link:plugins/slick/slick.css purge:false]
.link : plugins/slick/slick.css

. : map[external:false link:plugins/font-awesome/font-awesome.min.css purge:false]
.link : plugins/font-awesome/font-awesome.min.css

. : map[external:false link:plugins/venobox/venobox.css purge:false]
.link : plugins/venobox/venobox.css

. : map[external:false link:plugins/aos/aos.css purge:false]
.link : plugins/aos/aos.css
# CSS Plugins
[[params.plugins.css]]
link = "plugins/bootstrap/bootstrap.min.css"
external = false
purge = true
[[params.plugins.css]]
link = "plugins/slick/slick.css"
external = false
purge = false
[[params.plugins.css]]
link = "plugins/font-awesome/font-awesome.min.css"
external = false
purge = false
[[params.plugins.css]]
link = "plugins/venobox/venobox.css"
external = false
purge = false
[[params.plugins.css]]
link = "plugins/aos/aos.css"
external = false
purge = false
github.com/gohugoio/hugo/hugolib.(*Site).renderPages
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/hugolib/site_render.go:99
github.com/gohugoio/hugo/hugolib.(*Site).render
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/hugolib/site.go:1216
github.com/gohugoio/hugo/hugolib.(*HugoSites).render
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:325
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:149
runtime/trace.WithRegion
        /usr/local/Cellar/go/1.15.2/libexec/src/runtime/trace/annotation.go:137
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:151
github.com/gohugoio/hugo/commands.(*commandeer).rebuildSites
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/commands/hugo.go:768
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/commands/hugo.go:1133
github.com/gohugoio/hugo/commands.(*commandeer).newWatcher.func1
        /private/tmp/hugo-20201014-63001-1nmhq9g/hugo-0.76.5/src/github.com/gohugoio/hugo/commands/hugo.go:875
runtime.goexit
        /usr/local/Cellar/go/1.15.2/libexec/src/runtime/asm_amd64.s:1374

You’re trying to compare slices of maps. Maps are uncomparable types in the underlying Go code. intersect doesn’t support comparing slices of maps.

Ouch !!! Thanks a lot for the information.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.