Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3700

Go Map has wrong default value when optional

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.3
    • 0.11.0
    • Go - Compiler
    • None

    Description

      Template:

      struct TaskQuery {
          4: optional set<string> taskIds
      }
      

      renders in Golang as :

      TaskIds  map[string]bool         `thrift:"taskIds,4" json:"taskIds,omitempty"`
      

      In Golang, the default value for a map is simply an empty map and not nil, but the optional check

      func (p *TaskQuery) IsSetTaskIds() bool {
      	return p.TaskIds != nil
      }
      

      checks against nil instead if an empty map

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              connorgorman Connor Gorman
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: