essentialkaos / aligo Goto Github PK
View Code? Open in Web Editor NEWUtility for checking and viewing Golang struct alignment info
Home Page: https://kaos.sh/aligo
License: Apache License 2.0
Utility for checking and viewing Golang struct alignment info
Home Page: https://kaos.sh/aligo
License: Apache License 2.0
System info:
Steps to reproduce:
arena.go
with code//go:build goexperiment.arenas
package limited_arena
import (
"arena"
"github.com/Inspirate789/alloc/internal/limited_arena/constants"
"reflect"
"sync"
"sync/atomic"
"unsafe"
)
// Arena implements a size limit on the arena.Arena
type Arena struct {
arena *arena.Arena
free uintptr
}
type gcMetadata struct {
lastMarkID uint64
cyclicallyReferenced bool
referenceCount int // founded references (not all)
Finalized atomic.Bool
}
type ObjectMetadata struct {
sync.RWMutex
Address unsafe.Pointer
typeInfo reflect.Type
arena *Arena
gcMetadata
}
aligo -s ObjectMetadata view .
Expected behavior:
I'm expecting to get the result of analyzing the structure ObjectMetadata
.
Actual behavior:
I get a panic:
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
▾ github.com/Inspirate789/alloc/internal/limited_arena
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// arena.go:27 | Size: 88
type ObjectMetadata struct {
panic: interface conversion: types.Sizes is *types.gcSizes, not *types.StdSizes
goroutine 1 [running]:
github.com/essentialkaos/aligo/v2/inspect.GetMaxAlign(...)
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/inspect/inspect.go:81
github.com/essentialkaos/aligo/v2/cli.printCurrentFieldsInfo({0xc00036e940, 0x5, 0xc00003fbb0?})
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:278 +0x2e6
github.com/essentialkaos/aligo/v2/cli.printStructInfo(0xc0002615e0, 0x0)
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:257 +0xad
github.com/essentialkaos/aligo/v2/cli.PrintStruct(0xc00033f9e0, {0xc00027d4a0, 0xe}, 0x0)
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:66 +0xf9
github.com/essentialkaos/aligo/v2/cli.process({0xc00007e440, 0x2, 0x1?})
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/cli.go:203 +0x391
github.com/essentialkaos/aligo/v2/cli.Run({0x0, 0x0}, {0xb34f60, 0x15a, 0x15a})
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/cli.go:118 +0x631
main.main()
/home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/aligo.go:27 +0x36
Additional info:
Your source file inspect.go
where the panic is happening:
package inspect
// ...
// GetMaxAlign returns MaxAlign
func GetMaxAlign() int64 {
if Sizes == nil {
return 8
}
return Sizes.(*types.StdSizes).MaxAlign
}
I think the problem might be caused by the fact that I'm using //go:build goexperiment.arenas
, but it's not a good idea to convert interfaces so insecurely.
we are trying to use aligo in our project linter, but we face with this issue:
aligo --tags "" check ./...
panic: /opt/hostedtoolcache/go/1.20.7/x64/src/go/types/sizes.go:181: assertion failed
goroutine 1 [running]:
go/types.assert(0x18?)
the faild workflow
how can we fix it?
aligo fails with errors when some parts of the codebase are behind go build tags.
my codebase contains source files which are only included when run/compiled with the corresponding flag
(eg. go run -tags something ...
) will include files with //go:build something
at the top.
is there some way of passing these flags when executing aligo
so that these source files are included?
System info:
Steps to reproduce:
//go:build something
)aligo check ./...
or aligo view ./...
Expected behavior:
This behaviour is expected, it would be ideal if the -tags
CLI flag was supported so projects using build tags were supported.
eg. aligo -tags something check ./...
Actual behavior:
Errors are printed to the terminal such as undeclared name: XX
& XX not declared by package YY
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.