forked from cadey/xesite
Add gopreload as a dependency
This commit is contained in:
parent
62918fa6ea
commit
9b16f8a021
|
@ -0,0 +1,9 @@
|
||||||
|
// gopreload.go
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is separate to make it very easy to both add into an application, but
|
||||||
|
also very easy to remove.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import _ "github.com/Xe/gopreload"
|
|
@ -5,3 +5,4 @@ b68094ba95c055dfda888baa8947dfe44c20b1ac github.com/Xe/asarfs
|
||||||
33a50704c528b4b00db129f75c693facf7f3838b (dirty) github.com/Xe/asarfs
|
33a50704c528b4b00db129f75c693facf7f3838b (dirty) github.com/Xe/asarfs
|
||||||
5e4d0891fe789f2da0c2d5afada3b6a1ede6d64c layeh.com/asar
|
5e4d0891fe789f2da0c2d5afada3b6a1ede6d64c layeh.com/asar
|
||||||
3f7ce7b928e14ff890b067e5bbbc80af73690a9c github.com/urfave/negroni
|
3f7ce7b928e14ff890b067e5bbbc80af73690a9c github.com/urfave/negroni
|
||||||
|
f3687a5cd8e600f93e02174f5c0b91b56d54e8d0 github.com/Xe/gopreload
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
/*
|
||||||
|
Package gopreload is a bit of a hack to emulate the behavior of LD_PRELOAD [ld-preload].
|
||||||
|
This allows you to have automatically starting instrumentation, etc.
|
||||||
|
|
||||||
|
[ld-preload]: http://man7.org/linux/man-pages/man8/ld.so.8.html (see LD_PRELOAD section)
|
||||||
|
*/
|
||||||
|
package gopreload
|
|
@ -0,0 +1,26 @@
|
||||||
|
//+build linux,go1.8
|
||||||
|
|
||||||
|
package gopreload
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"plugin"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
gpv := os.Getenv("GO_PRELOAD")
|
||||||
|
if gpv == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, elem := range strings.Split(gpv, ",") {
|
||||||
|
log.Printf("gopreload: trying to open: %s", elem)
|
||||||
|
_, err := plugin.Open(elem)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%v from GO_PRELOAD cannot be loaded: %v", elem, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue