You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2013/07/25 23:17:51 UTC

[jira] [Comment Edited] (THRIFT-2007) Go generated code may fail with "illegal UTF-8 sequence" at "go run"

    [ https://issues.apache.org/jira/browse/THRIFT-2007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720072#comment-13720072 ] 

Jens Geyer edited comment on THRIFT-2007 at 7/25/13 9:17 PM:
-------------------------------------------------------------

That's interesting. I can't reproduce either, probably because someone had "fixed" this by just omitting the docstrings at this place. Try moving the docstring comment to somewhere else, e.g. a typedef:

{code}

namespace * Test

/** allowed range from -100 to +100 °C */
typedef list<foo>  foolist
{code}

results in 

{code}
package Test

// Autogenerated by Thrift Compiler (1.0.0-dev)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

import (
	"fmt"
	"math"
	"git.apache.org/thrift.git/lib/go/thrift"
)

// (needed to ensure safety because of naive import list constrution.)
var _ = math.MinInt32
var _ = thrift.ZERO
var _ = fmt.Printf

var GoUnusedProtection__ int;

//allowed range from -100 to +100 °C
type Foolist []*Foo

type Foo struct {
  Temperature float64 `thrift:"temperature,1"`
}

func NewFoo() *Foo {
  return &Foo{}
}

(more code)
{code}

and 

{code}
C:> thrift -gen go invalid-utf8.thrift
./gen-go//Test/ttypes.go:19:35: illegal UTF-8 encoding
WARNING - Running 'gofmt -w ./gen-go//Test/ttypes.go' failed.
{code}

                
      was (Author: jensg):
    Taht#s intereesting. I can't reproduce either, probably because someone had "fixed" this by just omitting the docstrings at this place. Try moving the docstring comment to somewhere else, e.g. a typedef:

{code}

namespace * Test

/** allowed range from -100 to +100 °C */
typedef list<foo>  foolist
{code}

results in 

{code}
package Test

// Autogenerated by Thrift Compiler (1.0.0-dev)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

import (
	"fmt"
	"math"
	"git.apache.org/thrift.git/lib/go/thrift"
)

// (needed to ensure safety because of naive import list constrution.)
var _ = math.MinInt32
var _ = thrift.ZERO
var _ = fmt.Printf

var GoUnusedProtection__ int;

//allowed range from -100 to +100 °C
type Foolist []*Foo

type Foo struct {
  Temperature float64 `thrift:"temperature,1"`
}

func NewFoo() *Foo {
  return &Foo{}
}

(more code)
{code}

and 

{code}
C:> thrift -gen go invalid-utf8.thrift
./gen-go//Test/ttypes.go:19:35: illegal UTF-8 encoding
WARNING - Running 'gofmt -w ./gen-go//Test/ttypes.go' failed.
{code}

                  
> Go generated code may fail with "illegal UTF-8 sequence" at "go run"
> --------------------------------------------------------------------
>
>                 Key: THRIFT-2007
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2007
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>         Environment: Windows (may be important)
>            Reporter: Jens Geyer
>            Priority: Minor
>         Attachments: invalid-utf8.thrift
>
>
> {code}
> struct foo {
>   /** allowed range from -100 to +100 °C */
>   1 :  double temperature
> }
> {code}
> Leads to
> {code}
> ./gen-go//Test/ttypes.go:18:52: illegal UTF-8 encoding
> WARNING - Running 'gofmt -w ./gen-go//Test/ttypes.go' failed.
> {code}
> followed by
> {code}
> $> go run hello.go
> # gen-go/S4P
> gen-go\S4P\ttypes.go:18: illegal UTF-8 sequence
>         b0 43
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira