Skip to content

Commit 10ba29a

Browse files
authored
all: add backward support for Go 1.16 (#13)
1 parent 08b9d79 commit 10ba29a

18 files changed

+350
-16
lines changed

.github/workflows/clipboard.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: [ubuntu-latest, macos-latest, windows-latest]
24+
go: [ '1.16.x', '1.17.x' ]
2425
steps:
2526
- name: Install and run dependencies (xvfb libx11-dev)
2627
if: ${{ runner.os == 'Linux' }}
@@ -47,24 +48,24 @@ jobs:
4748
- uses: actions/setup-go@v2
4849
with:
4950
stable: 'false'
50-
go-version: '1.17.x'
51+
go-version: ${{ matrix.go }}
5152

52-
- name: Build
53+
- name: Build (${{ matrix.go }})
5354
run: |
5455
go build -o gclip cmd/gclip/main.go
5556
go build -o gclip-gui cmd/gclip-gui/main.go
5657
57-
- name: Run Tests with CGO_ENABLED=1
58+
- name: Run Tests with CGO_ENABLED=1 (${{ matrix.go }})
5859
if: ${{ runner.os == 'Linux' || runner.os == 'macOS'}}
5960
run: |
6061
CGO_ENABLED=1 go test -v -covermode=atomic .
6162
62-
- name: Run Tests with CGO_ENABLED=0
63+
- name: Run Tests with CGO_ENABLED=0 (${{ matrix.go }})
6364
if: ${{ runner.os == 'Linux' || runner.os == 'macOS'}}
6465
run: |
6566
CGO_ENABLED=0 go test -v -covermode=atomic .
6667
67-
- name: Run Tests on Windows
68+
- name: Run Tests on Windows (${{ matrix.go }})
6869
if: ${{ runner.os == 'Windows'}}
6970
run: |
7071
go test -v -covermode=atomic .

clipboard_android.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build android
8+
// +build android
89

910
#include <android/log.h>
1011
#include <jni.h>

clipboard_android.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build android
8+
// +build android
89

910
package clipboard
1011

clipboard_darwin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build darwin && !ios
8+
// +build darwin,!ios
89

910
package clipboard
1011

clipboard_darwin.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build darwin && !ios
8+
// +build darwin,!ios
89

910
// Interact with NSPasteboard using Objective-C
1011
// https://developer.apple.com/documentation/appkit/nspasteboard?language=objc

clipboard_ios.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build ios
8+
// +build ios
89

910
package clipboard
1011

clipboard_ios.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build ios
8+
// +build ios
89

910
#import <UIKit/UIKit.h>
1011
#import <MobileCoreServices/MobileCoreServices.h>

clipboard_linux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build linux && !android
8+
// +build linux,!android
89

910
#include <stdlib.h>
1011
#include <stdio.h>

clipboard_linux.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Written by Changkun Ou <changkun.de>
66

77
//go:build linux && !android
8+
// +build linux,!android
89

910
package clipboard
1011

@@ -34,9 +35,10 @@ import (
3435
"fmt"
3536
"os"
3637
"runtime"
37-
"runtime/cgo"
3838
"time"
3939
"unsafe"
40+
41+
"golang.design/x/clipboard/internal/cgo"
4042
)
4143

4244
const errmsg = `Failed to initialize the X11 display, and the clipboard package

clipboard_nocgo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//go:build !windows && !cgo
2+
// +build !windows,!cgo
23

34
package clipboard
45

0 commit comments

Comments
 (0)