Loom - A repository for Weave Files
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
before_call_example
database_profiling
deferpanic_http
global_advice
go_routine_example
http_before_after_example
log_strconv_example
sample
static_validation
vizcli_example
LICENSE
README.md

README.md

loom

Loom - A repository for Weave Files

Used by 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 Examples

##Hello World Weave File:##

aspect {
  imports (
    "fmt"
  )
  pointcut: execute(*)
  advice: {
    before: {
      fmt.Println("hi")
    }
  }
}

Examples:

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

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

aspect {
  pointcut: execute(main())
  advice: {
    before: {
      fmt.Println("hello world")
    }
  }
}

Global Advice

aspect {
  pointcut: execute(*)
  advice: {
    before: {
      var globalCntr int = 0
    }
  }
}

Before Function Call

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))
    }
  }
}