Skip to content

Commit

Permalink
use const for field
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jun 28, 2024
1 parent adc84b5 commit ef543fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"github.com/gofrs/uuid/v5"
)

const (
CookieField = "cookie"
)

// PopulateFromCookies populates the fields of a struct based on cookie tags.
func PopulateFromCookies(r *http.Request, dest interface{}) error {
val := reflect.ValueOf(dest).Elem()
Expand All @@ -18,7 +22,7 @@ func PopulateFromCookies(r *http.Request, dest interface{}) error {
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
fieldType := typ.Field(i)
tag := fieldType.Tag.Get("cookie")
tag := fieldType.Tag.Get(CookieField)

if tag == "" {
continue
Expand Down

0 comments on commit ef543fb

Please sign in to comment.