{"id":23536876,"url":"https://github.com/peter-wangxu/goock","last_synced_at":"2025-07-12T01:33:14.442Z","repository":{"id":50099158,"uuid":"82013850","full_name":"peter-wangxu/goock","owner":"peter-wangxu","description":"A Go library and tool for discovering and managing block devices","archived":false,"fork":false,"pushed_at":"2023-03-29T13:41:04.000Z","size":1273,"stargazers_count":23,"open_issues_count":3,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-12T01:32:14.934Z","etag":null,"topics":["block-device","cli","golang-library","lun","rescan","storage-device","volume-discovery"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-wangxu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-15T02:55:54.000Z","updated_at":"2025-05-13T08:48:28.000Z","dependencies_parsed_at":"2024-06-19T01:32:04.165Z","dependency_job_id":"afbc1ed7-de18-4dde-b038-9c5087a406c6","html_url":"https://github.com/peter-wangxu/goock","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/peter-wangxu/goock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-wangxu%2Fgoock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-wangxu%2Fgoock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-wangxu%2Fgoock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-wangxu%2Fgoock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-wangxu","download_url":"https://codeload.github.com/peter-wangxu/goock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-wangxu%2Fgoock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264923076,"owners_count":23683717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["block-device","cli","golang-library","lun","rescan","storage-device","volume-discovery"],"created_at":"2024-12-26T02:36:57.999Z","updated_at":"2025-07-12T01:33:14.358Z","avatar_url":"https://github.com/peter-wangxu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goock\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/peter-wangxu/goock)](https://goreportcard.com/report/github.com/peter-wangxu/goock)\n[![CircleCI](https://img.shields.io/circleci/project/github/peter-wangxu/goock/master.svg?style=flat-square)](https://circleci.com/gh/peter-wangxu/goock)\n[![Codecov](https://img.shields.io/codecov/c/github/peter-wangxu/goock/master.svg?style=flat-square)](https://codecov.io/gh/peter-wangxu/goock)\n\nGoock is a `Golang` library/client for discovering and managing block device. it dramatically eases the\nefforts needed when connecting/disconnecting to storage backend.\n\n## Table of Content\n\n* [Overview](#overview)\n* [Features](#features)\n* [Installation](#installation)\n* [Requirements](#requirements)\n* [Usage](#usage)\n    * [As a library](#as-a-library)\n        * [Connect to a storage device](#connect-to-a-storage-device)\n        * [Disconnect a device from storage system](#disconnect-a-device-from-storage-system)\n    * [As a client](#as-a-client)\n        * [Show the goock version](#show-the-goock-version)\n        * [Connect to a LUN on specific target](#connect-to-a-lun-on-specific-target)\n        * [Connect and rescan all LUNs from a target](#connect-and-rescan-all-luns-from-a-target)\n        * [Disconnect a device from remote system](#disconnect-a-lun-from-storage-system)\n        * [Extend a connected device](#extend-a-connected-device)\n        * [Get command help](#get-help-of-each-command)\n* [Testing](#testing)\n    * [Unit test](#unit-test)\n    * [Manual test](#manual-test)\n* [Contributions](#contributions)\n* [License](#license)\n* [FAQ](#faq)\n\n\n## Overview\n\nGoock aims at providing a easy-to-use library/client for block device discovering and management. user no longer needs\nthe use of multiple linux tools like `open-iscsi`, `multipath-tools`, `sysfsutils` and `sg3-utils`). Instead,  \ngoock will leverage the power of many *nux device management tools, and provides simple and straightforward API/CLI for\ndevelopers and administrators.\n\n\nThis project is inspired by OpenStack project\n[os-brick](https://github.com/openstack/os-brick)\n\n## Features\n\n* Discovery of devices for iSCSI transport protocol.\n* Discovery of devices for FibreChanel transport protocol.\n* Removal of devices from a host\n* Multipath support\n\n## Installation\n\nNote: if you want build binary from source, please firstly [setup Go environment](https://golang.org/doc/).\n\n- Get the binary of goock, you have 2 ways to do this:\n\n    * Download the binary of goock from [goock releases](https://github.com/peter-wangxu/goock/releases)\n\n    * Either:\n        - download the source and it's dependencies from github\n    \n        ```\n        go get -d -v -t github.com/peter-wangxu/goock\n        ```\n        - Build the binary\n        \n        ```bash\n        go build\n        ```\n        a binary file named `goock` will be in place for use.\n\n- Install tools\n\nThis step installs couple of tools that goock relies on. \n\nOn Debian/Ubuntu\n```bash\nsudo apt-get install open-iscsi multipath-tools sysfsutils sg3-utils\n```\nOn RHEL/CentOS\n\n```bash\nyum install iscsi-initiator-utils device-mapper-multipath sysfsutils sg3_utils\n```\n## Development requirements\n\nGoock can be built or developed on both Linux or Windows platform.\n\n* Linux/Windows\n* Go 1.7 or later\n\n## Usage\n\n### As a library\n\nGoock is a library for connecting/disconnecting block devices for any Golang based\nsoftware. the example usage below:\n\n#### Connect to a storage device\n\n```go\npackage main\n\nimport (\n        \"github.com/peter-wangxu/goock/connector\"\n)\n\niscsi := connector.New()\n\nconn := connector.ConnectionProperty{}\nconn.TargetPortals = []string{\"192.168.1.30\"}\nconn.TargetIqns = []string{\"iqn.xxxxxxxxxxxxxx\"}\nconn.TargetPortals = []int{10}\n\ndeviceInfo, _ : = iscsi.ConnectVolume(conn)\n```\n\n#### Disconnect a device from storage system\n\n```go\npackage main\n\nimport (\n        \"github.com/peter-wangxu/goock/connector\"\n)\n\niscsi := connector.New()\n\nconn := connector.ConnectionProperty{}\nconn.TargetPortals = []string{\"192.168.1.30\"}\nconn.TargetIqns = []string{\"iqn.xxxxxxxxxxxxxx\"}\nconn.TargetPortals = []int{10}\n\ndeviceInfo, _ : = iscsi.DisconnectVolume(conn)\n```\n\n#### Extend a already connected device\n\nSometimes, the device needs be extended on the storage system, while host was not aware of size change immediately, in this case, a host side rescan is needed.\n\n```go\npackage main\n\nimport (\n        \"github.com/peter-wangxu/goock/connector\"\n)\n\niscsi := connector.New()\n\nconn := connector.ConnectionProperty{}\nconn.TargetPortals = []string{\"192.168.1.30\"}\nconn.TargetIqns = []string{\"iqn.xxxxxxxxxxxxxx\"}\nconn.TargetPortals = []int{10}\n\ndeviceInfo, _ : = iscsi.ExtendVolume(conn)\n```\n\n### As a client tool\n\nGoock is also client tool, which can be used from shell. When the host is connecting with\nbackend storage(such as enterprise array, DellEMC Unity, HPE 3Par etc.), goock can be helpful\nto connect with the storage device and inspect its information.\n\n\nNOTE: make sure you have permission to operate the block device.\n\n\nExample usage below:\n\n#### Show the goock version\n\n```bash\ngoock -v\n```\n#### Get host information\n\n```bash\ngoock info\n```\nthe output likes below:\n```bash\nVolume Information:\niSCSI Qualified Name(IQN)      :\niqn.1993-08.org.debian:01:b974ee37fea\nHost Bus Adapter               :\n[20000090fa534cd0:10000090fa534cd0 20000090fa534cd1:10000090fa534cd1]\nConnected Fibre Channel Target :\n[5006016089200925:5006016d09200925 50060160b6e00e5a:5006016036e00e5a 5006016089200925:5006016509200925 50060160b6e00e5a:5006016136e00e5a]\nConnected iSCSI sessions       :\n192.168.1.99 192.168.1.100\n```\n#### Connect to a LUN on specific target\n\n```bash\n# Connect and rescan storage device whose iSCSI target ip is \u003ctarget IP\u003e, the desired\n# Device LUN ID is [LUN ID]\ngoock connect \u003cTARGET\u003e \u003cLUN ID\u003e\n```\n\n\u003e The `\u003cTARGET\u003e` here and below commands example denotes the IP address or WWN of remote\nstorage device.\n\n\u003e The `\u003cLUN ID\u003e` is allocated by the storage array, usually a integer less than 255.\n\n#### Connect and rescan all LUNs from a target\n\n*Not support yet.*\n```bash\ngoock connect \u003cTARGET\u003e\n```\n\n#### Disconnect a LUN from storage system\n \n ```bash\n goock disconnect \u003cTarget\u003e \u003cLUN ID\u003e\n ```\n\n#### Extend a connected device\n\n```bash\ngoock extend \u003cTarget\u003e \u003cLUN ID\u003e\n```\nor\n\n*Not support yet.*\n```bash\ngoock extend /dev/sdx\n```\n\n#### Get help for each command\n\n```bash\ngoock help connect\n```\n## Testing\n\n### Unit test\n```bash\ncd goock\ngo test -v ./...\n```\n\n### Manual test\n\n* first build a binary from source\n\n```bash\ncd goock\ngo build\n```\n* run `goock` command by specifying some parameters\n```bash\ngoock connect \u003cTARGET\u003e \u003cLUN ID\u003e\n```\n\n\n## Contributions\n\nSimply fork this repo and send PR for your code change(also tests to cover your\nchange), remember to give a title and description of your PR.\n\n## License\n\n[Apache License Version 2.0](LICENSE)\n\n## FAQ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-wangxu%2Fgoock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-wangxu%2Fgoock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-wangxu%2Fgoock/lists"}