Home / Function/ decodePlain() — gin Function Reference

decodePlain() — gin Function Reference

Architecture documentation for the decodePlain() function in plain.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  b5ace19b_3649_4027_7b28_ebb24058f9d0["decodePlain()"]
  21e76dcb_3149_c38e_f1a2_e4347c4939cd["plain.go"]
  b5ace19b_3649_4027_7b28_ebb24058f9d0 -->|defined in| 21e76dcb_3149_c38e_f1a2_e4347c4939cd
  style b5ace19b_3649_4027_7b28_ebb24058f9d0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/plain.go lines 31–56

func decodePlain(data []byte, obj any) error {
	if obj == nil {
		return nil
	}

	v := reflect.ValueOf(obj)

	for v.Kind() == reflect.Ptr {
		if v.IsNil() {
			return nil
		}
		v = v.Elem()
	}

	if v.Kind() == reflect.String {
		v.SetString(bytesconv.BytesToString(data))
		return nil
	}

	if _, ok := v.Interface().([]byte); ok {
		v.SetBytes(data)
		return nil
	}

	return fmt.Errorf("type (%T) unknown type", v)
}

Subdomains

Defined In

Frequently Asked Questions

What does decodePlain() do?
decodePlain() is a function in the gin codebase, defined in binding/plain.go.
Where is decodePlain() defined?
decodePlain() is defined in binding/plain.go at line 31.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free