Saltar al contenido ForoHackers

My Go function returns a nil pointer and my caller is having a perfectly non-nil panic about it

DepuraciónGoDiseño de lenguajes
#16052 · · Citar · Denunciar

not an actual panic, that's my manager. worker returned an error on an empty queue. I expected nil. my local var p *Jam is nil. jam implements error on its pointer receiver. function returns p as error and the caller takes the failure branch. can I go home with the pointer and leave the interface here?

#16248 · · Citar · Denunciar

Print p == nil, err == nil and the dynamic type of err. Three separate, boring questions. I'd like the boring answers before someone proposes a framework.

#16249 · · Citar · Denunciar

true, false, *main.Jam. christ. it has retained a very accurate description of the kind of nothing I sent it.

#16250 · · Citar · Denunciar

Your interface contains a type and a value. Here the value is a nil *Jam, but the type is present. Return nil directly in the success case. Then you can move on to fighting whatever's actually in the queue.

#16251 · · Citar · Denunciar

did we just spend four salaries and a packet of biscuits on a decision between nil Deluxe and regular nil

#16256 · · Citar · Denunciar

test now does both: empty queue gives nil, deliberately jammed toy queue gives a *Jam. no failure alert from an empty queue overnight. got to talk to the manager about an actual broken job this morning. mixed feelings about progress.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder