func (g *goService) CommonError() string {
	return wrapGoType(g.commonError())
}
CommonError returns common error in go type
package output
import (
	"bytes"
	"fmt"
	"sort"
	"strconv"
	"strings"
	plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
	"github.com/yoozoo/protoapi/generator/data"
	"github.com/yoozoo/protoapi/util"
)
var _goServices []*goService
type goGen struct {
	DataTypes []*data.MessageData
	echoGen
}
type goService struct {
	*echoService
	Gen *goGen
}
func getGoPackageAndType(dataType string) (isFileToGenerate bool, pkg, refType string) {
	_, p := data.GetMessageProtoAndFile(dataType)
	isFileToGenerate = p.IsFileToGenerate
	pkg = p.Proto.GetOptions().GetGoPackage()
	structName := dataType[strings.LastIndex(dataType, ".")+1:]
	pkgName := pkg[strings.LastIndex(pkg, "/")+1:]
	if isFileToGenerate {
		refType = strings.Title(structName)
	} else {
		if pkgName == "" {
			refType = strings.Title(structName)
		} else {
			refType = pkgName + "." + strings.Title(structName)
		}
	}
	return
}
func appendGoImport(imports []string, dataType string) []string {
	if !strings.Contains(dataType, ".") {
		return imports
	}
	isFileToGenerate, pkg, refType := getGoPackageAndType(dataType)
	if !isFileToGenerate && !util.IsStrInSlice(`"`+pkg+`"`, imports) && pkg != "" {
		imports = append(imports, `"`+pkg+`"`)
	}
	importGoTypes[dataType] = refType
	return imports
}
func getGoImport(imports []string) (result string) {
	if len(imports) == 0 {
		return ""
	}
	sort.Slice(imports, func(i, j int) bool {
		return imports[i] > imports[j]
	})
	result = fmt.Sprintf(`import (
	%s
)
`, strings.Join(imports, "\n\t"))
	return
}
func (g *goService) Imports() (result string) {
	var imports []string
	for _, m := range g.Methods {
		imports = appendGoImport(imports, m.InputType)
		imports = appendGoImport(imports, m.OutputType)
		imports = appendGoImport(imports, m.ErrorType())
	}
	if g.HasCommonError() {
		imports = appendGoImport(imports, g.commonError())
	}
	return getGoImport(imports)
}
func (g *goService) commonError() string {
	return g.ServiceData.Options["common_error"]
}