https://github.com/deferpanic/loom
Loom - A repository for Weave Files
https://github.com/deferpanic/loom
Last synced: 4 months ago
JSON representation
Loom - A repository for Weave Files
- Host: GitHub
- URL: https://github.com/deferpanic/loom
- Owner: deferpanic
- License: mit
- Created: 2015-06-03T17:52:12.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-12T18:37:03.000Z (about 11 years ago)
- Last Synced: 2024-06-20T05:20:19.623Z (about 2 years ago)
- Language: Go
- Size: 1.71 MB
- Stars: 26
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loom
Loom - A repository for Weave Files
Used by [GoWeave](https://github.com/deferpanic/goweave)
A weave file contains aspects to weave into projects.
The weave file is subject to dramatic change right now. There is no
formal specification as of yet.
[Hello World](https://github.com/deferpanic/loom#examples)
[Examples](https://github.com/deferpanic/loom#examples)
##Hello World Weave File:##
```
aspect {
imports (
"fmt"
)
pointcut: execute(*)
advice: {
before: {
fmt.Println("hi")
}
}
}
```
### Examples:
[Loom](https://github.com/deferpanic/loom) has a listing of samples and
user-contributed weaves you might wish to look at or utilize.
Essentially we support aspect files w/in a project. If code exists in
your project we should be able to provide aspect coverage for it.
There are a few design decisions that need to be made to support across
projects && into stdlib. Stdlib probably won't come until we move to IR.
To try things out first try running `go build`. Then try running `goweave`.
#### Before Function Execution
```go
aspect {
pointcut: execute(beforeBob())
advice: {
before: {
fmt.Println("before bob")
}
}
}
```
#### After Function Execution
```
aspect {
pointcut: execute(afterAnnie())
advice: {
after: {
fmt.Println("after annie")
}
}
}
```
#### Before Main Execution
```go
aspect {
pointcut: execute(main())
advice: {
before: {
fmt.Println("hello world")
}
}
}
```
#### Global Advice
```go
aspect {
pointcut: execute(*)
advice: {
before: {
var globalCntr int = 0
}
}
}
```
#### Before Function Call
```go
aspect {
pointcut: call(beforeBob())
advice: {
before: {
fmt.Println("before bob")
}
}
}
```
#### After Function Call
```
aspect {
pointcut: call(afterAnnie())
advice: {
after: {
fmt.Println("after annie")
}
}
}
```
### Around Function Call
```
aspect {
pointcut: call(http.HandleFunc(d, s))
advice: {
around: {
http.HandleFunc(d, dps.HTTPHandlerFunc(s))
}
}
}
```