-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package oauth2 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
_ "unsafe" | ||
) | ||
|
||
var _ HMACPrefixFunc = getPrefix | ||
|
||
//go:linkname getPrefix | ||
func getPrefix(ctx context.Context, h *HMACSHAStrategy, part string) string { | ||
return fmt.Sprintf("ory_%s_", part) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package a | ||
|
||
import ( | ||
_ "unsafe" | ||
) | ||
|
||
func Foo() string { | ||
return Fooer() | ||
} | ||
|
||
//go:linkname Fooer github.com/ory/fosite/linkname/a.Fooer | ||
func Fooer() string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build !oel | ||
|
||
package a | ||
|
||
import ( | ||
_ "unsafe" | ||
) | ||
|
||
//go:linkname Fooer2 github.com/ory/fosite/linkname/a.Fooer | ||
func Fooer2() string { | ||
return "foo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build oel | ||
|
||
package b | ||
|
||
import ( | ||
"github.com/ory/fosite/linkname/a" | ||
_ "unsafe" | ||
) | ||
|
||
//go:linkname Fooer2 github.com/ory/fosite/linkname/a.Fooer | ||
func Fooer2() string { | ||
return "bar" | ||
} | ||
|
||
func Foo() string { | ||
return a.Foo() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
_ "unsafe" | ||
) | ||
|
||
//go:linkname pf fmt.Printf | ||
func pf(format string, a ...any) (n int, err error) { | ||
panic("") | ||
return 0, nil | ||
} | ||
|
||
//go:linkname timeNow time.Now | ||
func timeNow() time.Time { | ||
return time.Date(2040, 1, 1, 0, 0, 0, 0, time.UTC) | ||
} | ||
|
||
func main() { | ||
fmt.Printf("now: %v", time.Now()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package a | ||
|
||
import _ "unsafe" | ||
|
||
// fooer is an internal function in package a | ||
func fooer() string { | ||
return "foo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package b | ||
|
||
import ( | ||
_ "unsafe" | ||
_ "v2/a" | ||
) // required for go:linkname | ||
|
||
//go:linkname Fooer v2/a.fooer | ||
func Fooer() string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module v2 | ||
|
||
go 1.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"v2/b" // Import the overriding package to ensure it is included | ||
) | ||
|
||
func main() { | ||
fmt.Printf(b.Fooer()) // This should call the overridden function from package b | ||
} |