{"id":"d7d0dab03975ad84","repo":"jackc/pgx","slug":"structargs-requires-a-struct-or-pointer-to-struct","errorCode":null,"errorMessage":"StructArgs requires a struct or pointer to struct, got nil","messagePattern":"StructArgs requires a struct or pointer to struct, got nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"named_args.go","lineNumber":76,"sourceCode":"\t\treturn errorQueryRewriter{err: err}\n\t}\n\treturn NamedArgs(args)\n}\n\n// StrictStructArgs is like StructArgs but uses StrictNamedArgs rewriting\n// semantics (i.e. errors if the SQL query references missing arguments or if\n// extra arguments are provided).\nfunc StrictStructArgs(sa any) QueryRewriter {\n\targs, err := structArgs(sa)\n\tif err != nil {\n\t\treturn errorQueryRewriter{err: err}\n\t}\n\treturn StrictNamedArgs(args)\n}\n\nfunc structArgs(sa any) (map[string]any, error) {\n\tif sa == nil {\n\t\treturn nil, fmt.Errorf(\"StructArgs requires a struct or pointer to struct, got nil\")\n\t}\n\n\tv := reflect.ValueOf(sa)\n\tt := v.Type()\n\n\tif t.Kind() == reflect.Pointer {\n\t\tif v.IsNil() {\n\t\t\treturn nil, fmt.Errorf(\"StructArgs requires a non-nil pointer to struct\")\n\t\t}\n\t\tv = v.Elem()\n\t\tt = v.Type()\n\t}\n\n\tif t.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"StructArgs requires a struct or pointer to struct, got %s\", t)\n\t}\n\n\tout := make(map[string]any, t.NumField())","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/named_args.go#L58-L94","documentation":"Error \"StructArgs requires a struct or pointer to struct, got nil\" thrown in jackc/pgx.","triggerScenarios":"Thrown at named_args.go:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}