Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace empty slice literal with var #3337

Merged
merged 1 commit into from Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/goa/gen.go
Expand Up @@ -268,7 +268,8 @@ func cleanupDirs(cmd, output string) []string {
if err != nil {
return []string{gendirPath}
}
dirs := []string{}
var dirs []string

for _, fi := range finfos {
if fi.IsDir() {
dirs = append(dirs, filepath.Join(gendirPath, fi.Name()))
Expand Down
9 changes: 6 additions & 3 deletions http/codegen/openapi/v2/builder.go
Expand Up @@ -131,7 +131,8 @@ func mustGenerate(meta expr.MetaExpr) bool {
// addScopeDescription generates and adds required scopes to the scheme's description.
func addScopeDescription(scopes []*expr.ScopeExpr, sd *SecurityDefinition) {
// Generate scopes to add to description
lines := []string{}
var lines []string

for _, scope := range scopes {
lines = append(lines, fmt.Sprintf(" * `%s`: %s", scope.Name, scope.Description))
}
Expand Down Expand Up @@ -291,7 +292,8 @@ func paramsFromExpr(params *expr.MappedAttributeExpr, path string) []*Parameter
}

func paramsFromHeaders(endpoint *expr.HTTPEndpointExpr) []*Parameter {
params := []*Parameter{}
var params []*Parameter

var (
rma = endpoint.Service.Params
ma = endpoint.Headers
Expand Down Expand Up @@ -521,7 +523,8 @@ func buildPathFromExpr(s *V2, root *expr.RootExpr, h *expr.HostExpr, route *expr
key = expr.HTTPWildcardRegex.ReplaceAllString(key, "/{$1}")
params := paramsFromExpr(endpoint.Params, key)
params = append(params, paramsFromHeaders(endpoint)...)
produces := []string{}
var produces []string

responses := make(map[string]*Response, len(endpoint.Responses))
for _, r := range endpoint.Responses {
if endpoint.MethodExpr.IsStreaming() {
Expand Down
3 changes: 2 additions & 1 deletion http/codegen/openapi/v3/parameters.go
Expand Up @@ -33,7 +33,8 @@ func paramsFromPath(params *expr.MappedAttributeExpr, path string, rand *expr.Ex
// paramsFromHeadersAndCookies computes the OpenAPI spec parameters for the
// given endpoint HTTP headers and cookies.
func paramsFromHeadersAndCookies(endpoint *expr.HTTPEndpointExpr, rand *expr.ExampleGenerator) []*Parameter {
params := []*Parameter{}
var params []*Parameter

expr.WalkMappedAttr(endpoint.Headers, func(name, elem string, att *expr.AttributeExpr) error {
if strings.ToLower(elem) == "authorization" {
// Headers named "Authorization" are ignored by OpenAPI v3.
Expand Down