From 9b16f8a021d25eaedaec4726f5ee924a17615921 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 25 Mar 2017 11:01:39 -0700 Subject: [PATCH] Add gopreload as a dependency --- backend/christine.website/gopreload.go | 9 ++++++++ vendor-log | 1 + vendor/github.com/Xe/gopreload/doc.go | 7 ++++++ vendor/github.com/Xe/gopreload/preload.go | 26 +++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 backend/christine.website/gopreload.go create mode 100644 vendor/github.com/Xe/gopreload/doc.go create mode 100644 vendor/github.com/Xe/gopreload/preload.go diff --git a/backend/christine.website/gopreload.go b/backend/christine.website/gopreload.go new file mode 100644 index 0000000..6829ae5 --- /dev/null +++ b/backend/christine.website/gopreload.go @@ -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" diff --git a/vendor-log b/vendor-log index 0f1b968..25d1602 100644 --- a/vendor-log +++ b/vendor-log @@ -5,3 +5,4 @@ b68094ba95c055dfda888baa8947dfe44c20b1ac github.com/Xe/asarfs 33a50704c528b4b00db129f75c693facf7f3838b (dirty) github.com/Xe/asarfs 5e4d0891fe789f2da0c2d5afada3b6a1ede6d64c layeh.com/asar 3f7ce7b928e14ff890b067e5bbbc80af73690a9c github.com/urfave/negroni +f3687a5cd8e600f93e02174f5c0b91b56d54e8d0 github.com/Xe/gopreload diff --git a/vendor/github.com/Xe/gopreload/doc.go b/vendor/github.com/Xe/gopreload/doc.go new file mode 100644 index 0000000..720c5c1 --- /dev/null +++ b/vendor/github.com/Xe/gopreload/doc.go @@ -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 diff --git a/vendor/github.com/Xe/gopreload/preload.go b/vendor/github.com/Xe/gopreload/preload.go new file mode 100644 index 0000000..1b5a0c9 --- /dev/null +++ b/vendor/github.com/Xe/gopreload/preload.go @@ -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 + } + } +}