mirror of
https://github.com/prebid/openrtb.git
synced 2026-06-14 22:16:41 +03:00
ecd08d2d9a7dc1380d8fdb3639bd78c0e954fca6
go-rtb
Common OpenRTB v2.3 Object types and constants for Go programming language
Warning! Currently, this package is quite unstable (types and names may change). Also, even after v1.0 this repo will contain only recent version (v1+). So, if you need to use this code in production, take a look on godep.
Progress
- 3.2 Object Specifications
- 3.2.1 Object: BidRequest
- 3.2.2 Object: Imp
- 3.2.3 Object: Banner
- 3.2.4 Object: Video
- 3.2.5 Object: Native
- 3.2.6 Object: Site
- 3.2.7 Object: App
- 3.2.8 Object: Publisher
- 3.2.9 Object: Content
- 3.2.10 Object: Producer
- 3.2.11 Object: Device
- 3.2.12 Object: Geo
- 3.2.13 Object: User
- 3.2.14 Object: Data
- 3.2.15 Object: Segment
- 3.2.16 Object: Regs
- 3.2.17 Object: Pmp
- 3.2.18 Object: Deal
- 4.2 Object Specifications
- 4.2.1 Object: BidResponse
- 4.2.2 Object: SeatBid
- 4.2.3 Object: Bid
- Code quality/review
- Check types for struct keys (see Guidelines - Types)
- Use struct pointers for optional keys (e.g., App.Content)
- Make constants for section "5. Enumerated Lists Specification"
- Review and rename constants for types, if needed (see Guidelines - Naming convention)
- Add json directive "omitempty" for optional keys
Guidelines
Naming convention
- UpperCamelCase
- Capitalized abbreviations (e.g., AT, COPPA, PMP etc.)
- Capitalized ID keys
- Constants are named after type and key like
TypeName+KeyName+ValueDescription, e.g., constant fortype BidRequestwith keyATwill look likeconst BidRequestATFirstPrice
Types
- Key types should be chosen according to OpenRTB specification (attribute types)
- Numeric types:
- architecture-independent, e.g.,
int32instead ofint - signed integral types should be used only when absolutely needed (value may contain negative numbers), unsigned integral types are preferred
- enumerations should be represented with minimal integral types, e.g.,
uint8orint8for enumerations with <= 256 variants - for floating-point attributes only
float64type should be used
- architecture-independent, e.g.,
Documentation
- Godoc: documenting Go code
- Each entity (type, constant or struct key) should be documented
- Comments for entities should be copy-pasted "as-is" from OpenRTB specification
- For struct keys, section "Notes" may be added at the very bottom of key comment - it may contain some recommendations for developers (constants reference etc.)
Code organization
- Each RTB type and its related constants should be kept in its own file, named after type
- File names are in underscore_case, e.g.,
type BidRequestshould be declared inbid_request.go - go fmt your code
Languages
Go
100%