The package rpms/golang-github-alangpierce-forceexport.git has added or updated
architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/golang-github-alangpierce-forceex....
Change:
+%ifnarch s390x
Thanks.
Full change:
============
commit 3fc3dd8e5bfc41e6a6a5b9d69476b2244c046105
Author: Robert-Andr Mauchin <zebob.m(a)gmail.com>
Date: Wed Mar 4 17:36:02 2020 +0100
Disable s390x tests
Signed-off-by: Robert-Andr Mauchin <zebob.m(a)gmail.com>
diff --git a/golang-github-alangpierce-forceexport.spec
b/golang-github-alangpierce-forceexport.spec
index 40708ea..f0311a8 100644
--- a/golang-github-alangpierce-forceexport.spec
+++ b/golang-github-alangpierce-forceexport.spec
@@ -1,5 +1,7 @@
# Generated by go2rpm 1
+%ifnarch s390x
%bcond_without check
+%endif
#
https://github.com/alangpierce/go-forceexport
%global goipath
github.com/alangpierce/go-forceexport
commit b00e300feb1f4f6c39fe0a957965cdcb76f6082e
Author: Robert-Andr Mauchin <zebob.m(a)gmail.com>
Date: Wed Mar 4 17:23:08 2020 +0100
Initial import (#1802343)
Signed-off-by: Robert-Andr Mauchin <zebob.m(a)gmail.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..61ef4ca
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/go-forceexport-8f1d6941cd755b975763ddb1f836561edddac2b8.tar.gz
diff --git a/0001-Fixes-the-edge-case.patch b/0001-Fixes-the-edge-case.patch
new file mode 100644
index 0000000..d2fcb91
--- /dev/null
+++ b/0001-Fixes-the-edge-case.patch
@@ -0,0 +1,132 @@
+From af893c8a7b58060faaafaa545ac4d1e8874a3b44 Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Wed, 25 Apr 2018 01:29:49 -0400
+Subject: [PATCH 1/3] Fixes the edge case on the last function symbol that has
+ a nil datap
+
+---
+ forceexport.go | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/forceexport.go b/forceexport.go
+index 73714af..5b911e5 100644
+--- a/forceexport.go
++++ b/forceexport.go
+@@ -59,6 +59,21 @@ func FindFuncWithName(name string) (uintptr, error) {
+ for moduleData := &Firstmoduledata; moduleData != nil; moduleData = moduleData.next
{
+ for _, ftab := range moduleData.ftab {
+ f := (*runtime.Func)(unsafe.Pointer(&moduleData.pclntable[ftab.funcoff]))
++
++ // (*Func).Name() assumes that the *Func was created by some exported
++ // method that would have returned a nil *Func pointer IF the
++ // desired function's datap resolves to nil.
++ // (a.k.a. if findmoduledatap(pc) returns nil)
++ // Since the last element of the moduleData.ftab has a datap of nil
++ // (from experimentation), .Name() Seg Faults on the last element.
++ //
++ // If we instead ask the external function FuncForPc to fetch
++ // our *Func object, it will check the datap first and give us
++ // a proper nil *Func, that .Name() understands.
++ // The down side of doing this is that internally, the
++ // findmoduledatap(pc) function is called twice for every element
++ // we loop over.
++ f = runtime.FuncForPC(f.Entry())
+ if f.Name() == name {
+ return f.Entry(), nil
+ }
+
+From c453a2d8bacf5220393a99021007d7e40a4cb821 Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Wed, 25 Apr 2018 01:30:41 -0400
+Subject: [PATCH 2/3] Updated Moduledata to look more like go 1.10's ModuleData
+
+---
+ forceexport.go | 35 +++++++++++++++++++++++++++++++++--
+ 1 file changed, 33 insertions(+), 2 deletions(-)
+
+diff --git a/forceexport.go b/forceexport.go
+index 5b911e5..23dfda7 100644
+--- a/forceexport.go
++++ b/forceexport.go
+@@ -101,19 +101,50 @@ type Moduledata struct {
+ bss, ebss uintptr
+ noptrbss, enoptrbss uintptr
+ end, gcdata, gcbss uintptr
++ types, etypes uintptr
+
+- // Original type was []*_type
+- typelinks []interface{}
++ textsectmap []Textsect
++ typelinks []int32 // offsets from types
++ // Original type was []*itab
++ itablinks []*struct{}
++
++ ptab []PtabEntry
++
++ pluginpath string
++ // Original type was []modulehash
++ pkghashes []interface{}
+
+ modulename string
+ // Original type was []modulehash
+ modulehashes []interface{}
+
++ hasmain uint8 // 1 if module contains the main function, 0 otherwise
++
+ gcdatamask, gcbssmask Bitvector
+
++ // Original type was map[typeOff]*_type
++ typemap map[typeOff]*struct{}
++
++ bad bool // module failed to load and should be ignored
++
+ next *Moduledata
+ }
+
++type Textsect struct {
++ vaddr uintptr // prelinked section vaddr
++ length uintptr // section length
++ baseaddr uintptr // relocated section address
++}
++
++type nameOff int32
++type typeOff int32
++type textOff int32
++
++type PtabEntry struct {
++ name nameOff
++ typ typeOff
++}
++
+ type Functab struct {
+ entry uintptr
+ funcoff uintptr
+
+From 37ebe5b408f3c0e25d88a4b7980d633b88cb84a0 Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Wed, 25 Apr 2018 01:34:03 -0400
+Subject: [PATCH 3/3] Updated README.MD to indicate working status on GNU/Linux
+ Go 1.10rc2
+
+---
+ README.md | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/README.md b/README.md
+index 7e415e0..2c6aa04 100644
+--- a/README.md
++++ b/README.md
+@@ -10,9 +10,10 @@ by name.
+ As you might expect, this library is **unsafe** and **fragile** and probably
+ shouldn't be used in production. See "Use cases and pitfalls" below.
+
+-It has only been tested on Mac OS X with Go 1.6. If you find that it works or
+-breaks on other platforms, feel free to submit a pull request with a fix and/or
+-an update to this paragraph.
++It has only been tested on Mac OS X with Go 1.6 and on GNU/Linux with
++Go 1.10rc2.
++If you find that it works or breaks on other platforms, feel free to submit
++a pull request with a fix and/or an update to this paragraph.
+
+ ## Installation
+
diff --git a/0001-Minor-syntax-errors-in-test.patch
b/0001-Minor-syntax-errors-in-test.patch
new file mode 100644
index 0000000..4dfc54d
--- /dev/null
+++ b/0001-Minor-syntax-errors-in-test.patch
@@ -0,0 +1,107 @@
+From 34e2680236725e6a4da1ca253c01afc173f66d0d Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Tue, 24 Apr 2018 23:34:21 -0400
+Subject: [PATCH 1/3] Minor syntax errors in test - t.Error to t.Errorf
+
+---
+ forceexport_test.go | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/forceexport_test.go b/forceexport_test.go
+index 49b0f0e..32edf3c 100644
+--- a/forceexport_test.go
++++ b/forceexport_test.go
+@@ -41,7 +41,7 @@ func TestGetSelf(t *testing.T) {
+ var getFunc func(interface{}, string) error
+ err := GetFunc(&getFunc,
"github.com/alangpierce/go-forceexport.GetFunc")
+ if err != nil {
+- t.Error("Error: %s", err)
++ t.Errorf("Error: %s", err)
+ }
+ // The two functions should share the same code pointer, so they should
+ // have the same string representation.
+@@ -51,7 +51,7 @@ func TestGetSelf(t *testing.T) {
+ // Call it again on itself!
+ err = getFunc(&getFunc, "github.com/alangpierce/go-forceexport.GetFunc")
+ if err != nil {
+- t.Error("Error: %s", err)
++ t.Errorf("Error: %s", err)
+ }
+ if fmt.Sprint(getFunc) != fmt.Sprint(GetFunc) {
+ t.Errorf("Expected ")
+
+From a717f53cda07c750b3c58a305128deb8694872b6 Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Wed, 25 Apr 2018 01:06:22 -0400
+Subject: [PATCH 2/3] Evade go vet's error about function in fmt.Sprint
+
+---
+ forceexport_test.go | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/forceexport_test.go b/forceexport_test.go
+index 32edf3c..8dd518f 100644
+--- a/forceexport_test.go
++++ b/forceexport_test.go
+@@ -2,9 +2,16 @@ package forceexport
+
+ import (
+ "fmt"
++ "reflect"
++ "runtime"
+ "testing"
+ )
+
++// funcName resolves the name of a given function
++func funcName(f interface{}) string {
++ return runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
++}
++
+ func TestTimeNow(t *testing.T) {
+ var timeNowFunc func() (int64, int32)
+ GetFunc(&timeNowFunc, "time.now")
+@@ -45,7 +52,7 @@ func TestGetSelf(t *testing.T) {
+ }
+ // The two functions should share the same code pointer, so they should
+ // have the same string representation.
+- if fmt.Sprint(getFunc) != fmt.Sprint(GetFunc) {
++ if fmt.Sprint(funcName(getFunc)) != fmt.Sprint(funcName(GetFunc)) {
+ t.Errorf("Expected ")
+ }
+ // Call it again on itself!
+@@ -53,7 +60,7 @@ func TestGetSelf(t *testing.T) {
+ if err != nil {
+ t.Errorf("Error: %s", err)
+ }
+- if fmt.Sprint(getFunc) != fmt.Sprint(GetFunc) {
++ if fmt.Sprint(funcName(getFunc)) != fmt.Sprint(funcName(GetFunc)) {
+ t.Errorf("Expected ")
+ }
+ }
+
+From 5e795da1275d6bb103537d21d91c6310f24ffe9f Mon Sep 17 00:00:00 2001
+From: Craig Hesling <craig(a)hesling.com>
+Date: Wed, 25 Apr 2018 01:08:58 -0400
+Subject: [PATCH 3/3] Added rough benchmark
+
+---
+ forceexport_test.go | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/forceexport_test.go b/forceexport_test.go
+index 8dd518f..89edfb2 100644
+--- a/forceexport_test.go
++++ b/forceexport_test.go
+@@ -75,3 +75,12 @@ func TestInvalidFunc(t *testing.T) {
+ t.Error("Expected a nil function.")
+ }
+ }
++
++// BenchmarkGetMainInit check how long it takes to find the symbol main.init,
++// which is typically the last func symbol(by experiment).
++func BenchmarkGetMainInit(b *testing.B) {
++ for i := 0; i < b.N; i++ {
++ var main_init func()
++ GetFunc(&main_init, "main.init")
++ }
++}
diff --git a/golang-github-alangpierce-forceexport.spec
b/golang-github-alangpierce-forceexport.spec
new file mode 100644
index 0000000..40708ea
--- /dev/null
+++ b/golang-github-alangpierce-forceexport.spec
@@ -0,0 +1,56 @@
+# Generated by go2rpm 1
+%bcond_without check
+
+#
https://github.com/alangpierce/go-forceexport
+%global goipath
github.com/alangpierce/go-forceexport
+%global commit 8f1d6941cd755b975763ddb1f836561edddac2b8
+
+%gometa
+
+%global common_description %{expand:
+Go-forceexport is a golang package that allows access to any module-level
+function, even ones that are not exported. You give it the string name of a
+function , like "time.now", and gives you a function value that calls that
+function. More generally, it can be used to achieve something like reflection on
+top-level functions, whereas the reflect package only lets you access methods by
+name.}
+
+%global golicenses LICENSE
+%global godocs README.md
+
+Name: %{goname}
+Version: 0
+Release: 0.1%{?dist}
+Summary: Access unexported functions from other packages
+
+License: MIT
+URL: %{gourl}
+Source0: %{gosource}
+# Minor syntax errors in test
+Patch0:
https://patch-diff.githubusercontent.com/raw/alangpierce/go-forceexport/p...
+# Fixes the edge case
+Patch1:
https://patch-diff.githubusercontent.com/raw/alangpierce/go-forceexport/p...
+
+%description
+%{common_description}
+
+%gopkg
+
+%prep
+%goprep
+%patch0 -p1
+%patch1 -p1
+
+%install
+%gopkginstall
+
+%if %{with check}
+%check
+%gocheck
+%endif
+
+%gopkgfiles
+
+%changelog
+* Wed Mar 04 17:20:04 CET 2020 Robert-Andr Mauchin <zebob.m(a)gmail.com> -
0-0.1.20200304git8f1d694
+- Initial package
diff --git a/sources b/sources
new file mode 100644
index 0000000..0b6ccc9
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+SHA512 (go-forceexport-8f1d6941cd755b975763ddb1f836561edddac2b8.tar.gz) =
c292043842a6b4a9db10410533bfe05b86cdf697a785fc4d0321a76be91b8c712d79dc086bdde55a6ac8b90d95587e94d4bd6a2592df4445000292d0c8c532a0