microsoft/kiota

golang - Code is not correctly formatted

已关闭

#6,421 创建于 2025年4月7日

 (0 条评论) (0 个反应) (1 位负责人)C# (326 个派生)auto 404
Gohelp wantedtype:bug

仓库指标

星标
 (3,783 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Linux executable

Client library/SDK language

Go

Describe the bug

The current output of the golang generator is not formatted according to golangs style guide. This results in go fmt ./... touching those files after generation though it's not necessary (golang maintainers say, all generated code needs to be correctly formatted https://github.com/golang/go/issues/73181#issuecomment-2780661979).

Expected behavior

There are several issues like newlines, extra parentheses, import ordering and so on

I created a PR over here https://github.com/microsoft/kiota/pull/6416 trying to address those issues

How to reproduce

  1. Generate a client with the integration test as a base
rm -rf ./golangtest/
cp -r ./it/go golangtest
dotnet build
./src/kiota/bin/Debug/net9.0/kiota generate --openapi https://aka.ms/graph/v1.0/openapi.yaml --output ./golangtest/client --language go --exclude-backward-compatible --clean-output -i '/groups/getByIds#POST' -n 'integrationtest/client'
  1. Add a baseline to git
cd golangtest
git init
git add .
  1. Run go fmt and view the diff (the diff should be empty)
go fmt ./...
git diff

Open API description file

No response

Kiota Version

latest

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

No response

Other information

No response

贡献者指南