Skip to content

Naming Style for Go: same name in package is not allowed #6

@huan

Description

@huan

Questions from WIP: add user/message.go #4

Q1

Q1: Go does not allow const of the same name and different types in the same package; so I changed the name of the constant, which may differ from the community specification, I wonder if it is appropriate?

I understand the naming style is different between the language specifications.

From TypeScript to Go means, we have to change some of our naming specifications so that the code can fit the Go styles.

My opinion is: we should follow the style from TS Wechaty as our default, and only change it when there's a must.

For the Go Lang, I believe we can follow another official style which will be a perfect match: @chatie/grpc (Wechaty has dependency to this module)

You can find the Image definition here:

https://github.com/Chatie/grpc/blob/ab85b7345b90c167a031710b9a819f9220c09002/proto/wechaty/puppet/message.proto#L25-L30

enum ImageType {
  IMAGE_TYPE_UNSPECIFIED = 0;
  IMAGE_TYPE_THUMBNAIL   = 1;
  IMAGE_TYPE_HD          = 2;
  IMAGE_TYPE_ARTWORK     = 3;
}

Which means in Go, we can align to:

  ImageTypeUnspecified ImageType = 0
  ImageTypeThumbnail = 1
  ImageTypeHd = 2
  ImageTypeArtwork = 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions