panic adding default value to .proto file

I’m trying to set a default, by changing

fs.FilesystemEncoderType encoder_type = 35;


fs.FilesystemEncoderType encoder_type = 35 [(ext.default) = "passthru"];

But I get the panic below raised here. I’ve tried all kinds of workarounds, but nothing’s worked. Any ideas why this is panicking? It appears to me I’m exactly mimicking CopyRangeMethod which works, so I’m stumped.

panic: fs.FilesystemEncoderType [recovered]
        panic: fs.FilesystemEncoderType

goroutine 1 [running]: +0xa5
panic({0x13e3a00, 0x12ffcc0})
        runtime/panic.go:1038 +0x215{0x13d2720, 0xc000304398}) +0x838{0x13ada80, 0xc000304398}) +0x26a{0x13dc9a0, 0xc000304000}) +0x26a{0x13dcc20, 0xc000304000}) +0x26a{_, _}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}) +0x65{0xc0000316b0, 0x30}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...) +0x11a
main.loadOrDefaultConfig({0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...) +0x86
main.maybeReportPanics() +0x6a
main.monitorMain({{0x0}, 0x0, 0x0, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, 0x0}, ...}) +0x545
main.serveOptions.Run({{0x0}, 0x0, 0x0, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, 0x0}, ...}) +0x75d{0x13ef6a0, 0x1db7780, 0x1d46e20}, {0x13fb22e, 0x4}, {0xc0001cdc08, 0x0, 0xc0001cdbb8})
        reflect/value.go:543 +0x814
reflect.Value.Call({0x13ef6a0, 0x1db7780, 0x10}, {0xc0001cdc08, 0x0, 0x0})
        reflect/value.go:339 +0xc5{0x13fac3f, 0x3}, {0x13ef6a0, 0x1db7780, 0x3}, {0x13ef6a0, 0x1db7780, 0xc675c5}, 0xc00015e500) +0x4e7*Context).RunNode(0xc00015cd80, 0xc00017a380, {0x0, 0x0, 0x0}) +0x40b*Context).Run(0x128bba0, {0x0, 0x0, 0x0}) +0xa5
main.main() +0x3af

goroutine 6 [chan receive]:*recursiveTree).dispatch(0xc0000766e0) +0x4d
created by +0x15b

goroutine 8 [select]:
main.(*autoclosedFile).closerLoop(0xc0002ee2a0) +0x77
created by main.newAutoclosedFile +0x1e7

goroutine 9 [syscall]:
        runtime/sigqueue.go:169 +0x98
        os/signal/signal_unix.go:24 +0x19
created by os/signal.Notify.func1.1
        os/signal/signal.go:151 +0x2c

Did you copy the marshalling/unmarshalling stuff as well, with the ParseDefault method? That’s needed to convert the string to the enum.

Yes, it’s at lib/fs/encoder_types.go. Everything runs fine without the

[(ext.default) = "passthru"]

But when I add it, it panics on Linux and Windows. I haven’t tried cross-compiling yet.

You lack the ParseDefault method.


You’re right. I’m an idiot. I had copy/pasted from lib/fs/types.go which doesn’t have ParseDefault. I should have used lib/fs/copyrangemethod.go. Thanks for catching, and sorry for the noise.