-
Notifications
You must be signed in to change notification settings - Fork 5
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
0 parents
commit 82b8bda
Showing
11 changed files
with
217 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: test | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
# - ubuntu-latest | ||
- macOS-latest | ||
- windows-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
- name: Setup X server on ubuntu-latest | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt update -y | ||
sudo apt install -y xorg openbox | ||
sudo startx | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.x | ||
- name: Add $GOPATH/bin to $PATH | ||
run: echo "::add-path::$(go env GOPATH)/bin" | ||
- name: Test | ||
run: make test |
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,25 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# GoLand | ||
.idea/ | ||
|
||
# Executable Binary | ||
clipboard | ||
|
||
# Go test coverage | ||
c.out | ||
coverage.html |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Tsuji Daishiro | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,33 @@ | ||
.PHONY: all build test lint clean deps devel-deps | ||
|
||
BIN := clipboard | ||
BUILD_LDFLAGS := "-s -w" | ||
GOBIN ?= $(shell go env GOPATH)/bin | ||
export GO111MODULE=on | ||
|
||
all: clean build | ||
|
||
deps: | ||
go mod tidy | ||
|
||
devel-deps: deps | ||
GO111MODULE=off go get -u \ | ||
golang.org/x/lint/golint | ||
|
||
build: clean | ||
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) | ||
|
||
test: deps | ||
go test -v -race -count=1 ./... | ||
|
||
test-cover: deps | ||
go test -v -race -count=1 ./... -cover -coverprofile=c.out | ||
go tool cover -html=c.out -o coverage.html | ||
|
||
lint: devel-deps | ||
go vet ./... | ||
$(GOBIN)/golint -set_exit_status ./... | ||
|
||
clean: | ||
rm -rf $(BIN) | ||
go clean |
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 @@ | ||
# clipboard | ||
|
||
"clipboard" is a multi-platform clipboard library in Go. | ||
|
||
## Abstract | ||
|
||
- This is clipboard library in Go, which runs on multiple platforms. | ||
- External clipboard package is not required. | ||
|
||
## Supported Platforms | ||
|
||
- Windows | ||
- macOS | ||
|
||
### ⚠WIP⚠ | ||
|
||
- Linux, Unix (X11) |
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,11 @@ | ||
package clipboard | ||
|
||
// Get returns the current text data of the clipboard. | ||
func Get() (string, error) { | ||
return get() | ||
} | ||
|
||
// Set sets the current text data of the clipboard. | ||
func Set(text string) error { | ||
return set(text) | ||
} |
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,20 @@ | ||
// +build darwin | ||
|
||
package clipboard | ||
|
||
import ( | ||
"git.wow.st/gmp/clip" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
func set(text string) error { | ||
ok := clip.Set(text) | ||
if !ok { | ||
return xerrors.New("nothing to set string") | ||
} | ||
return nil | ||
} | ||
|
||
func get() (string, error) { | ||
return clip.Get(), nil | ||
} |
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,21 @@ | ||
package clipboard | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestCopyAndPaste(t *testing.T) { | ||
want := "gopher" | ||
if err := Set(want); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
got, err := Get() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if got != want { | ||
t.Errorf("CopyAndPaste mismatch: got %v, want %v", got, want) | ||
} | ||
} |
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,15 @@ | ||
// +build windows | ||
|
||
package clipboard | ||
|
||
import "github.com/lxn/walk" | ||
|
||
func get() (string, error) { | ||
c := walk.Clipboard() | ||
return c.Text() | ||
} | ||
|
||
func set(text string) error { | ||
c := walk.Clipboard() | ||
return c.SetText(text) | ||
} |
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 @@ | ||
module github.com/d-tsuji/clipboard | ||
|
||
go 1.14 | ||
|
||
require ( | ||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5 | ||
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1 | ||
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4 // indirect | ||
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f // indirect | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 | ||
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect | ||
) |
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,13 @@ | ||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5 h1:OKeTjZST+/TKvtdA258NXJH+/gIx/xwyZxKrAezNFvk= | ||
git.wow.st/gmp/clip v0.0.0-20191001134149-1458ba6a7cf5/go.mod h1:NLdpaBoMQNFqncwP8OVRNWUDw1Kt9XWm3snfT7cXu24= | ||
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1 h1:/QwQcwWVOQXcoNuV9tHx30gQ3q7jCE/rKcGjwzsa5tg= | ||
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= | ||
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4 h1:5BmtGkQbch91lglMHQ9JIDGiYCL3kBRBA0ItZTvOcEI= | ||
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4/go.mod h1:ouWl4wViUNh8tPSIwxTVMuS014WakR1hqvBc2I0bMoA= | ||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f h1:mOhmO9WsBaJCNmaZHPtHs9wOcdqdKCjF6OPJlmDM3KI= | ||
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc= | ||
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E= |