kiota icon indicating copy to clipboard operation
kiota copied to clipboard

golang - Code is not correctly formatted

Open firefart opened this issue 9 months ago • 0 comments

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

firefart avatar Apr 07 '25 13:04 firefart