add extension readme
This commit is contained in:
parent
247a9df679
commit
f0f0604d5a
@ -4,6 +4,6 @@ All notable changes to the "goc" extension will be documented in this file.
|
||||
|
||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||
|
||||
## [Unreleased]
|
||||
## 0.0.3 2020-09-02
|
||||
|
||||
- Initial release
|
@ -1,3 +1,44 @@
|
||||
# Goc Coverage README
|
||||
# Goc Coverage
|
||||
|
||||
**Enjoy!**
|
||||
This extension provides rich support for the [goc](https://github.com/qiniu/goc) tool.
|
||||
|
||||
## Overview
|
||||
|
||||
* [Getting started](#getting-started)
|
||||
* [Ask for help](#ask-for-help)
|
||||
|
||||
## Getting started
|
||||
|
||||
Welcome! The [goc](https://github.com/qiniu/goc) is a coverage tool for Golang projects. The most interesting part of [goc](https://github.com/qiniu/goc) is that it can generate coverage report while the service is running! You can test the service manually or automatically, whatever, you don't have to stop the tested service to get the coverage report anymore.
|
||||
|
||||
This extension provides a frontend to show the covered lines in real time.
|
||||
|
||||
### Basic requirements
|
||||
|
||||
Before you started, make sure that you have:
|
||||
|
||||
1. Go
|
||||
2. [goc](https://github.com/qiniu/goc)
|
||||
3. source code of the tested service
|
||||
|
||||
### Set up your environment
|
||||
|
||||
Follow the [goc example](https://github.com/qiniu/goc#examples) guide to build and start the tested service. After you finished this step, there should be a **goc server** running at default port `7777`.
|
||||
|
||||
Use `vscode` to open the source code. Make sure the vscode's `workspace` is in the Golang project's root directory. If your project uses `go module`, just open vscode in the repo's directory. If your project uses `GOPATH`, you should setup right `GOPATH` before you open vscode.
|
||||
|
||||
Open any Go source files, you should see a `Goc Coverage OFF` button in the bottom status bar, click on the button to enable rendering covered lines in real time.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### goc server url
|
||||
|
||||
If you deploy the goc server on another host with a customized port, you can set:
|
||||
|
||||
```
|
||||
"goc.serverUrl": "http://192.168.1.3:51234"
|
||||
```
|
||||
|
||||
## Ask for help
|
||||
|
||||
If you're having issues with this extension, please reach out to us by [filing an issue](https://github.com/qiniu/goc/issues/new/choose) directly.
|
@ -2,7 +2,7 @@
|
||||
"name": "goc",
|
||||
"displayName": "Goc Coverage",
|
||||
"description": "Goc Coverage can display coverage vairation in real time. Goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing code coverage collection and accurate testing.",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.3",
|
||||
"publisher": "lyyyuna",
|
||||
"repository": {
|
||||
"url": "https://github.com/qiniu/goc"
|
||||
|
@ -16,6 +16,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
let disposable2 = vscode.commands.registerCommand('extension.switch', async () => {
|
||||
if (gocStatusBarItem.text == 'Goc Coverage OFF') {
|
||||
let err = gocserver.checkGoEnv()
|
||||
// check if pc meets extension's requirement
|
||||
if (err) {
|
||||
vscode.window.showErrorMessage('Cannot get Golang version, please check your go environment.')
|
||||
return
|
||||
}
|
||||
gocStatusBarItem.text = 'Goc Coverage ON';
|
||||
// get current project package structure
|
||||
let packages = gocserver.getGoList();
|
||||
|
@ -67,6 +67,15 @@ export class GocServer {
|
||||
return "";
|
||||
}
|
||||
|
||||
checkGoEnv() : Boolean {
|
||||
let output = spawnSync('go', ['version']);
|
||||
if (output.status != 0 || output.status == null) {
|
||||
console.error(output.stderr.toString())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getGoList(): Array<any> {
|
||||
let cwd = "";
|
||||
let workspaces = vscode.workspace.workspaceFolders || [];
|
||||
@ -80,7 +89,7 @@ export class GocServer {
|
||||
'cwd': cwd
|
||||
};
|
||||
let output = spawnSync('go', ['list', '-json', './...'], opts);
|
||||
if (output.error != null) {
|
||||
if (output.status != 0 || output.status == null) {
|
||||
console.error(output.stderr.toString());
|
||||
return [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user