From 607b8178dc16e3ff962cd8c5ca7511bff44ea57e Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Mon, 2 Oct 2023 08:28:11 -0700 Subject: [PATCH] Fix gen.go, formatting --- gen.ps1 | 14 ++++++++++++++ spec/gen.go | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 gen.ps1 diff --git a/gen.ps1 b/gen.ps1 new file mode 100644 index 0000000..c933543 --- /dev/null +++ b/gen.ps1 @@ -0,0 +1,14 @@ +$DebugPreference = 'Continue' +$ErrorActionPreference = 'Stop' + +Set-PSDebug -Off +Set-StrictMode -Version 'Latest' -ErrorAction 'Stop' -Verbose + +New-Variable -Name curdir -Option Constant -Value $PSScriptRoot + +$specDir = Resolve-Path -LiteralPath (Join-Path -Path $curdir -ChildPath 'spec') +$amqpSpecXml = Resolve-Path -LiteralPath (Join-Path -Path $specDir -ChildPath 'amqp0-9-1.stripped.extended.xml') +$gen = Resolve-Path -LiteralPath (Join-Path -Path $specDir -ChildPath 'gen.go') +$spec091 = Resolve-Path -LiteralPath (Join-Path -Path $curdir -ChildPath 'spec091.go') + +Get-Content -LiteralPath $amqpSpecXml | go run $gen | gofmt | Set-Content -Force -Path $spec091 diff --git a/spec/gen.go b/spec/gen.go index c0f7518..7b640f5 100644 --- a/spec/gen.go +++ b/spec/gen.go @@ -15,14 +15,15 @@ import ( "fmt" "io" "log" + "os" "regexp" "strings" "text/template" ) var ( - ErrUnknownType = errors.New("Unknown field type in gen") - ErrUnknownDomain = errors.New("Unknown domain type in gen") + ErrUnknownType = errors.New("unknown field type in gen") + ErrUnknownDomain = errors.New("unknown domain type in gen") ) var amqpTypeToNative = map[string]string{ @@ -147,17 +148,17 @@ var ( // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. - /* GENERATED FILE - DO NOT EDIT */ - /* Rebuild from the spec/gen.go tool */ + /* GENERATED FILE - DO NOT EDIT */ + /* Rebuild from the spec/gen.go tool */ - {{with .Root}} - package amqp091 + {{with .Root}} + package amqp091 - import ( - "fmt" - "encoding/binary" - "io" - ) + import ( + "fmt" + "encoding/binary" + "io" + ) // Error codes that can be sent from the server during a connection or // channel exception or used by the client to indicate a class of error like @@ -241,7 +242,7 @@ var ( switch mf.MethodId { {{range .Methods}} case {{.Index}}: // {{$class.Name}} {{.Name}} - //fmt.Println("NextMethod: class:{{$class.Index}} method:{{.Index}}") + // fmt.Println("NextMethod: class:{{$class.Index}} method:{{.Index}}") method := &{{$.StructName $class.Name .Name}}{} if err = method.read(r.r); err != nil { return @@ -434,7 +435,7 @@ func (renderer *renderer) Domain(field Field) (domain Domain, err error) { } } return domain, nil - //return domain, ErrUnknownDomain + // return domain, ErrUnknownDomain } func (renderer *renderer) FieldName(field Field) (t string) {