Come kill some bugs with me!

Ok so I’m getting pretty close to cracking this thing and finally getting the first draft of my personal site up and running. I tracked what I think is the last error down but the thing is that whenever I work that error out, it causes an event to occur that creates another error. :sweat_smile: The repo can be found at this link.

So here’s the what the original error looked like:

Started building sites ...
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}

goroutine 1 [running]:*Site).loadData(0xc420090000, 0xc420757798, 0x2, 0x2, 0xbd702b, 0x2)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x86e*Site).readDataFromSourceFS(0xc420090000, 0xbe193b, 0xa)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x186*Site).process(0xc420090000, 0x101, 0xc420cd6b40, 0x458c53, 0x458c53)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x96*HugoSites).process(0xc42018b0b0, 0xc420cd6b30, 0x0, 0x0, 0x0, 0x0, 0x0)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x126*HugoSites).Build(0xc42018b0b0, 0x101, 0x0, 0x0, 0x0, 0x0, 0xc4201d36e8, 0xc4200eda30)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x102*commandeer).buildSites(0xc4201e7620, 0x1, 0x0, 0xc4201d3680)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0xb5*commandeer).build(0xc4201e7620, 0xc4200edade, 0x1, 0x1, 0xc4201f75f0, 0x16)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0xa7, 0xc420016b80, 0x0, 0x1, 0x0, 0x0)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x87a*Command).execute(0xf97400, 0xc420016b30, 0x1, 0x1, 0xf97400, 0xc420016b30)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x457*Command).ExecuteC(0xf95b40, 0xc16628, 0x405edc, 0xc42001a178)
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x339
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x60
   /build/hugo-gtPQ98/hugo-0.25.1/obj-x86_64-linux-gnu/src/ +0x36

So I tried a few things and eventually ended up making that go away by getting rid of the data/devicons.json file. Which in turn led to me getting this error:

WARNING: calling IsSet with unsupported type “string” (string) will always return false.
ERROR 2018/03/29 23:25:01 Error while rendering “home”: template: /home/jdbohrman/Dropbox/ (Resume)/layouts/index.html:4:10: executing “main” at <partial "portfolio/s…>: error calling partial: template: partials/portfolio/skills.html:15:55: executing “partials/portfolio/skills.html” at <$.Site.Data.devicons>: devicons is not a method but has arguments

So obviously something is wrong somewhere, but I don’t feel confident enough to find it on my own. any help will be rewarded with virtual high fives.

Oh and here’s line 15 of partials/skills.html:

<i class="devicons devicons-{{ if $.Site.Data.devicons (lower .name) }}{{ lower .name }}{{ else }}terminal_badge{{ end }}"></i>

If you want to access data in a map, you can either use the .key notation (like you do .devicons) or the index function. When the key name is variable, you must use index to access it.

Here the template engine thinks you called the $.Site.Data.devicons function with one param (lower .name). But you want to get the (lower .name) key in the devicons map.

This one is because you wrote if isset . "name", but most of the time, skills is a list of strings, so isset will produce a warning and always return false (which is what you expected). However, you may achieve the same thing without a warning by actually checking the type of the variable, like so:

{{ range .skills }}
  {{ if eq "string" (printf "%T" .) }}
    {{ . }}
  {{ else }}
    {{ .name }}
{{ end }}

Which leads me to the last obvious thing that I see. On line 15, you use .name multiple times. However, you’re in the situation where .name does not exist.

Hope that helps :slight_smile:

Here’s what I have right now. Still getting the error but I think I widdled some things down. I’m starting to understand what’s going on.

  <i class="devicons devicons-{{ index .Site.Data.key (lower .name) }}{{ lower .name }}"></i>

Awesome I’m trying that right now.

Are you reffering to the fact I don’t have names appear at all in data/devicons.json? I’m still learning how some of these things work and kinda picking some things up as I go. I’m assuming it’s trying to pull the names key and there’s nothing there but I could be wrong.


If I remember correctly, I was more talking about your use of with, a function that changes the context. The notion of context is explained here.

with does context rebinding to leave available for you only the variable you passed to it and the global page context (respectively . and $). So if you do with .name, in your block, .name becomes a simple dot .

That’s a bit weird to bump your post without providing more context, information about your trials of what did or didn’t work. Especially since your Github repo for your site is no longer available to try and help you out :wink: