Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/note-cli
go 1.15

replace github.com/blues/note-cli/lib => ./lib
replace github.com/blues/note-go => ./note-go

// uncomment this for easier testing locally
// replace github.com/blues/note-go => ../hub/note-go
Expand Down
90 changes: 90 additions & 0 deletions note-go/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build-unix-and-windows:
docker:
- image: circleci/golang:1.14.4
working_directory: /go/src/github.com/blues/note-go
steps:
- checkout
- run: export GOOS=linux GOARCH=amd64 ; ./build.sh && ./package.sh
- run: export GOOS=linux GOARCH=arm ; ./build.sh && ./package.sh
- run: export GOOS=windows GOARCH=386 ; ./build.sh && ./package.sh
- run: export GOOS=windows GOARCH=amd64 ; ./build.sh && ./package.sh
- run: find ./build/ -type f
- store_artifacts:
path: ./build/packages/
- persist_to_workspace:
root: .
paths:
- ./build/packages/
build-macos:
macos:
xcode: 11.3.0
steps:
- checkout
- run: pwd
- run: echo $PATH
- run:
name: install go
command: |
curl https://dl.google.com/go/go1.14.4.darwin-amd64.tar.gz |
tar -C "$HOME" -xz # install go to $HOME/go/
- run:
name: build and package
command: |
export PATH="$PATH:$HOME/go/bin"
./build.sh
./package.sh
- store_artifacts:
path: ./build/packages/
- persist_to_workspace:
root: .
paths:
- ./build/packages/
publish-github-release:
docker:
- image: cibuilds/github:0.10
steps:
# We need to do a checkout so the CIRCLE_PROJECT_REPONAME and CIRCLE_SHA1 vars are populated
# for the command below.
- checkout
- attach_workspace:
at: .
- run: ls -l ./build/packages/
- run:
name: "Publish Release on GitHub"
command: |
ghr -t "${GITHUB_TOKEN}" -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" \
-c "${CIRCLE_SHA1}" -delete "${CIRCLE_TAG}" ./build/packages/
# The GITHUB_TOKEN is generated here: https://github.com/settings/tokens for the
# notebot-ci user and securely set here:
# https://app.circleci.com/settings/project/github/blues/note-go/environment-variables

workflows:
version: 2
build-and-publish:
jobs:
- build-macos:
filters:
# Because we don't filter out certain branches this code implicitly says `build-macos`
# will run for all builds triggered by a branch push or PR. But in the circle-ci ui we
# chose to only build for PRs here:
# https://app.circleci.com/settings/project/github/blues/note-go/advanced
tags: &PUBLISH_TAG_FILTER_REGEX
# Unlike branch-triggered builds, we do filter down to certain tags. Match v1.2.3 etc.
# i.e. the only tags which can trigger must look like they're tagging a release.
only: /^v\d+\.\d+\.\d+$/
- build-unix-and-windows:
filters:
tags: *PUBLISH_TAG_FILTER_REGEX
- publish-github-release:
requires:
- build-macos
- build-unix-and-windows
filters:
branches:
ignore: /.*/
tags: *PUBLISH_TAG_FILTER_REGEX
36 changes: 36 additions & 0 deletions note-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# jetbrains IDEs config files
**/.idea
build

# Production build proucts
./build/

# 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

# auto- generated files #
######################
*~
\#*\#
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# VS Code configuration files
.vscode/*
# whitelist
!.vscode/launch.json
18 changes: 18 additions & 0 deletions note-go/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to ./notecard",
"type": "go",
"request": "attach",
"mode":"local",
"processId": 6968, // Fill this in with the PID of your notecard process.
"remotePath": "/go/src/github.com/blues/note-go",
// Sadly this doesn't work. Even if you set isBackground on the task.
//"preLaunchTask": "Compose w/ Debuggable Noteboard",
},
],
}
7 changes: 7 additions & 0 deletions note-go/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Code of conduct

By participating in this project, you agree to abide by the
[Blues Inc code of conduct][1].

[1]: https://blues.github.io/opensource/code-of-conduct

64 changes: 64 additions & 0 deletions note-go/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Contributing to blues/note-go

We love pull requests from everyone. By participating in this project, you
agree to abide by the Blues Inc [code of conduct].

[code of conduct]: https://blues.github.io/opensource/code-of-conduct

Here are some ways *you* can contribute:

* by using alpha, beta, and prerelease versions
* by reporting bugs
* by suggesting new features
* by writing or editing documentation
* by writing specifications
* by writing code ( **no patch is too small** : fix typos, add comments,
clean up inconsistent whitespace )
* by refactoring code
* by closing [issues][]
* by reviewing patches

[issues]: https://github.com/blues/note-go/issues

## Submitting an Issue

* We use the [GitHub issue tracker][issues] to track bugs and features.
* Before submitting a bug report or feature request, check to make sure it
hasn't
already been submitted.
* When submitting a bug report, please include a [Gist][] that includes a stack
trace and any details that may be necessary to reproduce the bug, including
your release version, Go version, and operating system. Ideally, a bug report
should include a pull request with failing specs.

[gist]: https://gist.github.com/

## Cleaning up issues

* Issues that have no response from the submitter will be closed after 30 days.
* Issues will be closed once they're assumed to be fixed or answered. If the
maintainer is wrong, it can be opened again.
* If your issue is closed by mistake, please understand and explain the issue.
We will happily reopen the issue.

## Submitting a Pull Request
1. [Fork][fork] the [official repository][repo].
2. [Create a topic branch.][branch]
3. Implement your feature or bug fix.
4. Add, commit, and push your changes.
5. [Submit a pull request.][pr]

## Notes
* Please add tests if you changed code. Contributions without tests won't be
* accepted. If you don't know how to add tests, please put in a PR and leave a
* comment asking for help. We love helping!

[repo]: https://github.com/blues/note-go/tree/master
[fork]: https://help.github.com/articles/fork-a-repo/
[branch]:
https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
[pr]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/

Inspired by
https://github.com/thoughtbot/factory_bot/blob/master/CONTRIBUTING.md

19 changes: 19 additions & 0 deletions note-go/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2019 Blues Inc

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.
32 changes: 32 additions & 0 deletions note-go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# [Blues Wireless][blues]

The note-go Go library for communicating with Blues Wireless Notecard via serial or I²C.

This library allows you to control a Notecard by coding in Go.
Your program may configure Notecard and send Notes to [Notehub.io][notehub].

See also:
* [note-c][note-c] for C bindings
* [note-python][note-python] for Python bindings

## Installing
For all releases, we have compiled the notecard utility for different OS and architectures [here](https://github.com/blues/note-go/releases).
If you don't see your OS and architecture supported, please file an issue and we'll add it to new releases.

[blues]: https://blues.com
[notehub]: https://notehub.io
[note-arduino]: https://github.com/blues/note-arduino
[note-c]: https://github.com/blues/note-c
[note-go]: https://github.com/blues/note-go
[note-python]: https://github.com/blues/note-python

## Dependencies
- Install Go and the Go tools [(here)](https://golang.org/doc/install)

## Compiling the notecard utility
If you want to build the latest, follow the directions below.
```bash
$ cd tools/notecard
$ go get -u .
$ go build .
```
38 changes: 38 additions & 0 deletions note-go/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /usr/bin/env bash
#
# Copyright 2020 Blues Inc. All rights reserved.
# Use of this source code is governed by licenses granted by the
# copyright holder including that found in the LICENSE file.
#
######### Bash Boilerplate ##########
set -euo pipefail # strict mode
readonly SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPT_DIR" # cd to this script's dir
######### End Bash Boilerplate ##########

#
# note-go build.sh
#
# This script builds all the note-go executables (note, notecard, notehub) by
# looking for any folder containing a main.go and running `go build`.
#
# Parameters: Set $GOOS and $GOARCH to cross compile for different platforms.
#
# Output: Executables are saved in "./build/$GOOS/$GOARCH/"
#

# Add GOOS and GOARCH to our environment. (and other GO vars we don't need)
eval "$(go env)"

readonly BUILD_EXE_DIR="$SCRIPT_DIR/build/$GOOS/$GOARCH/"
mkdir -p "$BUILD_EXE_DIR"

# Build each executable binary
# build_dirs is an array of all the folders which contain a main.go
IFS=$'\r\n' GLOBIGNORE='*' command eval 'build_dirs=($(find . -name main.go -print0 | xargs -0n1 dirname))'
for dir in "${build_dirs[@]}"; do
(
cd "$dir"
go build ${GO_BUILD_FLAGS:-} -o "$BUILD_EXE_DIR"
)
done
17 changes: 17 additions & 0 deletions note-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/blues/note-go

// 2023-02-26 Raspberry Pi apt-get only is updated to 1.15
go 1.15

require (
github.com/gofrs/flock v0.7.1
github.com/shirou/gopsutil/v3 v3.21.6
github.com/stretchr/testify v1.7.0
go.bug.st/serial v1.6.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
periph.io/x/conn/v3 v3.7.0
periph.io/x/host/v3 v3.8.0
)
39 changes: 39 additions & 0 deletions note-go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shirou/gopsutil/v3 v3.21.6 h1:vU7jrp1Ic/2sHB7w6UNs7MIkn7ebVtTb5D9j45o9VYE=
github.com/shirou/gopsutil/v3 v3.21.6/go.mod h1:JfVbDpIBLVzT8oKbvMg9P3wEIMDDpVn+LwHTKj0ST88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4=
github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
go.bug.st/serial v1.6.1 h1:VSSWmUxlj1T/YlRo2J104Zv3wJFrjHIl/T3NeruWAHY=
go.bug.st/serial v1.6.1/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
periph.io/x/conn/v3 v3.7.0/go.mod h1:ypY7UVxgDbP9PJGwFSVelRRagxyXYfttVh7hJZUHEhg=
periph.io/x/d2xx v0.1.0/go.mod h1:OflHQcWZ4LDP/2opGYbdXSP/yvWSnHVFO90KRoyobWY=
periph.io/x/host/v3 v3.8.0 h1:T5ojZ2wvnZHGPS4h95N2ZpcCyHnsvH3YRZ1UUUiv5CQ=
periph.io/x/host/v3 v3.8.0/go.mod h1:rzOLH+2g9bhc6pWZrkCrmytD4igwQ2vxFw6Wn6ZOlLY=
Loading