spf13 / spf13/cast

cast protobuf enum return 0

Open
#163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
4k
Forks
337
Avg merge
15m
Merged PRs (30d)
1

Description

version: 1.5 1.3

test.proto

enum N {
   DEFAULT = 0;
   ONE =  1;
}

message Test {
    N  num  = 1;
}

main.go

a := &pb.Test{ Num:  123 }

cast.toInt32(a)   //return 0
int32(a)   //return 123

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test.proto and main.go examples, then trace cast.toInt32 for the protobuf enum field. Reproduce the difference between cast.toInt32(a) and int32(a), and consider the issue done when the cast returns the enum's numeric value rather than 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.