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
  2c8f4300_4578_490e_1b63_60449a7173e6["decodePlain()"]
  3f4ea77d_d86e_1cba_2ad6_73447dbad2a3["Bind()"]
  3f4ea77d_d86e_1cba_2ad6_73447dbad2a3 -->|calls| 2c8f4300_4578_490e_1b63_60449a7173e6
  83d68aba_4c9c_5df3_ae33_41c7905cba21["BindBody()"]
  83d68aba_4c9c_5df3_ae33_41c7905cba21 -->|calls| 2c8f4300_4578_490e_1b63_60449a7173e6
  style 2c8f4300_4578_490e_1b63_60449a7173e6 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)
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does decodePlain() do?
decodePlain() is a function in the gin codebase.
What calls decodePlain()?
decodePlain() is called by 2 function(s): Bind, BindBody.

Analyze Your Own Codebase

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

Try Supermodel Free