Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hiwakaba committed Sep 24, 2020
0 parents commit 72ed10e
Show file tree
Hide file tree
Showing 56 changed files with 6,050 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#### Relevant Issue (if applicable)
(If there are Issues related to this PullRequest, please list it.)

#### Details
(Please describe the details of PullRequest.)

44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- published

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.14'
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
- name: Check golang version
run: go version
- name: Check env
run: env
- name: Init
run: make init
- name: Test
run: make test
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# emacs backup files
*.go~
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hirotaka Wakabayashi <hiwakaba@yahoo-corp.jp>
Takeshi Nakatani <ggtakec@gmail.com>
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k2hash_go (1.0.0) stable; urgency=low

* Initial commit

-- Hirotaka Wakabayashi <hiwakaba@yahoo-corp.jp> Fri, 17 Apr 2020 07:40:05 +0000
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Yahoo Japan Corporation

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.
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# k2hash_go
#
# Copyright 2018 Yahoo Japan Corporation.
#
# Go driver for k2hash that is a NoSQL Key Value Store(KVS) library.
# For k2hash, see https://github.com/yahoojapan/k2hash for the details.
#
# For the full copyright and license information, please view
# the license file that was distributed with this source code.
#
# AUTHOR: Hirotaka Wakabayashi
# CREATE: Fri, 14 Sep 2018
# REVISION:
#

build:
# use _build as the GOPATH-base
@/bin/echo "Running k2hash_go build"
GOPATH=$(PWD)/_build go install -v github.com/yahoojapan/k2hash_go/...
@echo "OK - built the following binaries:"
ls -l _build/bin

init:
# 0. remove the build directory
rm -fr _build
# 1. get source.
@echo "Running k2hash_go init (fetching source code)"
git clone https://github.com/yahoojapan/k2hash_go.git _build/src/github.com/yahoojapan/k2hash_go
# 2. syntax check.
BAD_GOFMT_FILES=$(find ./_build -name '*.go' | xargs gofmt -l)
@echo ".go files that are not gofmt-compliant (empty if all are fine): [$(BAD_GOFMT_FILES)]"
# 3. install libk2hash
sh utils/libk2hash.sh

test:
@echo "Running k2hash_go test"
GOPATH=$(PWD)/_build go test -v github.com/yahoojapan/k2hash_go/tests
GOPATH=$(PWD)/_build go test -v github.com/yahoojapan/k2hash_go/tests -coverprofile=c.out
GOPATH=$(PWD)/_build go tool cover -html=c.out

publish:
@echo "Running k2hash_go publish"
# TODO: add scp of binaries to Artifactory (or RPM package creation and uploading)

# Local Variables:
# c-basic-offset: 4
# tab-width: 4
# indent-tabs-mode: t
# End:
# vim600: noexpandtab sw=4 ts=4 fdm=marker
# vim<600: noexpandtab sw=4 ts=4

98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# k2hash_go

### Overview

**k2hash_go** implements a [k2hash](https://k2hash.antpick.ax/) client in golang.

### Install

Firstly you must install the [k2hash](https://k2hash.antpick.ax/) shared library.
```
$ curl -o- https://raw.github.com/yahoojapan/k2hash_go/master/utils/libk2hash.sh | bash
```
You can install **k2hash** library step by step from [source code](https://github.com/yahoojapan/k2hash). See [Build](https://k2hash.antpick.ax/build.html) for details.

After you make sure you set the [GOPATH](https://github.com/golang/go/wiki/SettingGOPATH) environment, download the **k2hash_go** package.
```
$ go get -u github.com/yahoojapan/k2hash_go
```

### Usage

Here is a simple example of **k2hash_go** which save a key and get it.

```golang
package main

import (
"fmt"
"os"

"github.com/yahoojapan/k2hash_go/k2hash"
)

func SetAndGet() {
// 1. Instantiate K2hash class
file, _ := k2hash.NewK2hash("/tmp/test.k2h")
defer file.Close()
ok, err := file.Set("hello", "world")
if ok != true {
fmt.Fprintf(os.Stderr, "file.Set(hello, world) returned false, err %v\n", err)
}
// 2. Get
// 2.1. no args
val, err := file.Get("hello")
if val == nil || err != nil {
fmt.Fprintf(os.Stderr, "file.Get(hello) returned val %v err %v\n", val, err)
return
}
fmt.Printf("val = %v, err = %v\n", val.String(), err)
}

func main() {
SetAndGet()
}
```

### Development

Here is the step to start developing **k2hash_go**.

- Debian / Ubuntu

```bash
#!/bin/sh

sudo apt-get update -y && sudo apt-get install curl git -y && curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.deb.sh | sudo bash
sudo apt-get install libfullock-dev k2hash-dev -y
go get github.com/yahoojapan/k2hash_go/k2hash

exit 0
```

- CentOS / Fedora

```bash
#!/bin/sh

sudo dnf makecache && sudo yum install curl git -y && curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.rpm.sh | sudo bash
sudo dnf install libfullock-devel k2hash-devel -y
go get github.com/yahoojapan/k2hash_go/k2hash

exit 0
```

### Documents
- [About K2HASH](https://k2hash.antpick.ax/)
- [About AntPickax](https://antpick.ax/)

### License

MIT License. See the LICENSE file.

## AntPickax

[AntPickax](https://antpick.ax/) is
- an open source team in [Yahoo Japan Corporation](https://about.yahoo.co.jp/info/en/company/).
- a product family of open source software developed by [AntPickax](https://antpick.ax/).

6 changes: 6 additions & 0 deletions examples/getattr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# getattr

```
$ go build
$ ./getattr
```
Loading

0 comments on commit 72ed10e

Please sign in to comment.