detached 05c9a4c

playground support (#220)

Currently, if a package imports purego in the playground even if none of the functions are called the run will fail with a complaint about unable to link in libdl.so.2. This commit circumvents this by stubbing out the dynamic linking pragmas for the go playground (//go:build faketime). This allows building and running apps in the playground that import purego but doesn't allow actually calling any of the functions. Currently, it will just die very ungracefully.
commit
05c9a4c9920cb33c831a1294362f858ce11579ac
author
TotallyGamerJet · · 2024-03-28 02:55 UTC
committer
GitHub · · 2024-03-28 02:55 UTC
parent
1673152
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
2 files · +21 -1
M dlfcn_nocgo_linux.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo
4+//go:build !cgo && !faketime
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo4+//go:build !cgo && !faketime
5 5
6 package purego6 package purego
7 7
A dlfcn_playground.go +20 -0
@@ -0,0 +1,20 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3+
4+//go:build faketime
5+
6+package purego
7+
8+import _ "unsafe"
9+
10+// The playground doesn't support dynamic linking so just stub out the addresses
11+var (
12+ //go:linkname purego_dlopen purego_dlopen
13+ purego_dlopen uintptr
14+ //go:linkname purego_dlsym purego_dlsym
15+ purego_dlsym uintptr
16+ //go:linkname purego_dlerror purego_dlerror
17+ purego_dlerror uintptr
18+ //go:linkname purego_dlclose purego_dlclose
19+ purego_dlclose uintptr
20+)
@@ -0,0 +1,20 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3+
4+//go:build faketime
5+
6+package purego
7+
8+import _ "unsafe"
9+
10+// The playground doesn't support dynamic linking so just stub out the addresses
11+var (
12+ //go:linkname purego_dlopen purego_dlopen
13+ purego_dlopen uintptr
14+ //go:linkname purego_dlsym purego_dlsym
15+ purego_dlsym uintptr
16+ //go:linkname purego_dlerror purego_dlerror
17+ purego_dlerror uintptr
18+ //go:linkname purego_dlclose purego_dlclose
19+ purego_dlclose uintptr
20+)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close