Skip to content

Proto consideration #63

@nigeltiany

Description

@nigeltiany

Thank you for the library.

Consider generating device/os/browser types from a proto file. Proto enums are easily upgraded should new device/os/browser coverage be needed. They also present the advantage of being referenced by other definitions. Take google/protobuf/empty.proto for example. A simple empty proto easy to create but referenced by many. Or google/protobuf/timestamp.proto. It is commonly used because it ensures a timestamp with milliseconds and/or nanoseconds precision is parsed around between services needing it. It would be good to parse these device/os/browser types as types and not as strings. Users not needing the proto definitions can continue to use the library as usual.

types
   | -> device
         | -> device.go
         | -> device.proto
         | -> device.pb.go
   | -> os
   ...

device.go

type Device struct {
   device DeviceType // from proto
   version string // or struct with major(), minor(), patch()
}

device.proto

syntax = "proto3";
option go_package = "github.com/avct/uasurfer/types/device";
enum DeviceType {
 unknown = 0;
 ...
};

or Device type can be a message

syntax = "proto3";
option go_package = "github.com/avct/uasurfer/types/device";
message Device {
  DeviceType deviceType = 1;
  Version version = 2;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions