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 合併指標
 (平均合併 3天 22小時) (30 天內合併 79 個 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

貢獻者指南