Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

The provider service

The first and easiest service to implement is Provider. The following is the definition for the Provider type and its constructor:

type Provider struct {
    vendorID string
}

func NewProvider(vendorID string) *Provider {
    return &Provider{ vendorID: vendorID }
}

Next, we will implement the GetQuote method, as specified in the preceding protocol buffer definitions. To keep our example as simple as possible, we will provide a dummy implementation that returns a single quote with a random price value and the vendorID value that was passed as an argument to the NewProvider constructor:

func (p *Provider) GetQuote(ctx context.Context, req *proto.QuotesRequest) (*proto.QuotesResponse, error) {
    return &proto.QuotesResponse{ Quotes: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content