記事編集ページのセレクトバーはカテゴリテーブルのrangeで回していたが、
valueに編集する記事レコードのcategoryIdをselectedとしてどう表示するか。。
<select class="form-select" name="categoryId" aria-label="Default select example">
<option selected>カテゴリを選択</option>
{{ range .Category }}
{{ if eq .ID .Art.CategoryId }}
<option value="{{ .ID }}" selected>{{ .Name }}</option>
{{ else }}
<option value="{{ .ID }}">{{ .Name }}</option>
{{ end }}
{{ end }}
</select>
これだと
executing "content" at <.Art.CategoryId>: can't evaluate field Art in type models.Category
exit status 1
.Category rangeの中に.Art.CategoryIdなんてありません、と怒られますが。。
{{ if eq .ID .Art.CategoryId }}
この部分を
{{ if eq .ID $.Art.CategoryId }}
$をつけてあげることで、range外の変数を返せるようです.