github.com/jujuyuki/gospal@v1.0.1-0.20210215170718-af79fae13b20/README.md (about) 1 # gospal 2 3 ## Go Static Program AnaLysing framework 4 5 This is a research prototype static analyser for Go programs. 6 In particular, this is a fork of [the original prototype](https://github.com/nickng/gospal) 7 that was designed around message-passing. 8 Currently the framework consists of two main tools, `migoinfer` and `ssaview`, but it 9 should be able to build more backends with different output formats based on this framework. 10 11 To build the tool, use `go get`: 12 13 ``` 14 go get github.com/jujuyuki/gospal/cmd/... 15 ``` 16 17 ### migoinfer 18 19 The MiGo infer tool (`cmd/migoinfer`) infers [extended MiGo 20 types](http://github.com/jujuyuki/migo) from a Go source code. The formal 21 definitions of the MiGo types were first defined in 22 [this paper](http://mrg.doc.ic.ac.uk/publications/fencing-off-go-liveness-and-safety-for-channel-based-programming/), 23 and extended for shared memory primitives in a paper currently accepted at ECOOP 2020 (to appear). 24 The format of the output in textual form is described in the 25 [migo](https://github.com/jujuyuki/migo/blob/master/README.md) package. 26 27 For example, given this sample program `main.go`, 28 29 ``` 30 package main 31 32 func main() { 33 ch := make(chan int) 34 go Sender(ch) 35 fmt.Println(<-ch) 36 } 37 38 func Sender(ch chan int) { 39 ch <- 1 40 } 41 ``` 42 43 This is the expected output of the inference, with additional output `def`s that 44 does not involve communication. 45 46 ``` 47 $ migoinfer main.go 48 49 def main.main(): 50 let t0 = newchan main.main0.t0_chan0, 0; 51 spawn main.Sender(t0); 52 recv t0; 53 def main.Sender(ch): 54 send ch 55 ``` 56 57 **This is a research prototype and does not cover all features of Go**. 58 Please report errors with a small fragment of sample code and what you 59 expect to see, however, noting that it might not be possible to infer the 60 types soundly due to the limitations of static analysis. 61 62 ### ssaview 63 64 The SSA viewer (`cmd/ssaview`) is a wrapper over the 65 [`ssa`](http://golang.org/x/tools/go/ssa) package from the extra tools of the Go 66 project for viewing SSA-form of a given source code. It is similar to 67 [`ssadump`](https://golang.org/x/tools/cmd/ssadump) but shares the build 68 configuration with the `migoinfer` tool in this project.