package stockprice
import . "goa.design/goa/v3/dsl"
// API describes the global properties of the API server.
var _ = API("api", func() {
Title("Calculator Service")
Description("HTTP service for multiplying numbers, a goa teaser")
Server("calc", func() {
Host("localhost", func() { URI("http://localhost:8088") })
})
})
// Service describes a service
var _ = Service("calc", func() {
Description("The calc service performs operations on numbers")
// Method describes a service method (endpoint)
Method("multiply", func() {
// Payload describes the method payload
// Here the payload is an object that consists of two fields
Payload(func() {
// Attribute describes an object field
Attribute("a", Int, "Left operand")
Attribute("b", Int, "Right operand")
// Both attributes must be provided when invoking "multiply"
Required("a", "b")
})
// Result describes the method result
// Here the result is a simple integer value
Result(Int)
// HTTP describes the HTTP transport mapping
HTTP(func() {
// Requests to the service consist of HTTP GET requests
// The payload fields are encoded as path parameters
GET("/multiply/{a}/{b}")
// Responses use a "200 OK" HTTP status
// The result is encoded in the response body
Response(StatusOK)
})
})
})
and install goa using go install goa.design/goa/v3/cmd/goa@v3.
As first step did the go mod init stockprice which works perfectly setting up go.mod. Then execute goa to generate the code:
goa gen stockprice --output gen
goa example stockprice --output gen
One the generated file that resides inside gen/calc.go
package api
import (
"context"
"log"
calc "stockprice/gen/gen/calc"
"goa.design/clue/log"
)
// calc service example implementation.
// The example methods log the requests and return zero values.
type calcsrvc struct{}
// NewCalc returns the calc service implementation.
func NewCalc() calc.Service {
return &calcsrvc{}
}
// Multiply implements multiply.
func (s *calcsrvc) Multiply(ctx context.Context, p *calc.MultiplyPayload) (res int, err error) {
log.Printf(ctx, "calc.multiply")
return
}
This file throws an error when compiling as compiler complained about 2 different log package. Commenting the log package fix the issue. The other information that I can provide the GOPATH pkg has the following package version goa.design/goa/v3@v3.17.2
Hi,
I'm using the example
design.go
and install
goa
usinggo install goa.design/goa/v3/cmd/goa@v3
.As first step did the
go mod init stockprice
which works perfectly setting upgo.mod
. Then executegoa
to generate the code:One the generated file that resides inside
gen/calc.go
This file throws an error when compiling as compiler complained about 2 different
log
package. Commenting thelog
package fix the issue. The other information that I can provide the GOPATHpkg
has the following package versiongoa.design/goa/v3@v3.17.2
Looking through the closed PR noticed there is a PR that added the new
god.design/clue/log
https://github.com/goadesign/goa/pull/3547.Was wondering if this want intentional ? or a bug ?