Permalink
Browse files

Fix lint

  • Loading branch information...
1 parent 697d90f commit 73898f8400bf704ef014cae5f0cf358d8419aa3e @haya14busa committed Sep 1, 2016
Showing with 10 additions and 6 deletions.
  1. +3 −0 goplay.go
  2. +6 −6 goplay_test.go
  3. +1 −0 socket/client.go
View
@@ -14,6 +14,7 @@ import (
const defaultBaseURL = "https://play.golang.org"
+// DefaultClient is default Go Playground client.
var DefaultClient = &Client{}
var delay = time.Sleep
@@ -50,6 +51,7 @@ func (c *Client) compileEndpoint() string {
return c.baseURL() + "/compile"
}
+// Run runs code which compiled in The Go Playground.
func (c *Client) Run(code io.Reader, stdout io.Writer, stderr io.Writer) error {
resp, err := c.Compile(code)
if err != nil {
@@ -69,6 +71,7 @@ func (c *Client) Run(code io.Reader, stdout io.Writer, stderr io.Writer) error {
return nil
}
+// Compile compiles code on The Go Playground.
func (c *Client) Compile(code io.Reader) (*Response, error) {
b, err := ioutil.ReadAll(code)
if err != nil {
View
@@ -16,14 +16,14 @@ func TestClient_Run(t *testing.T) {
defer func() { delay = saveDelay }()
events := []*Event{
- &Event{Message: "out1", Kind: "stdout", Delay: 5},
- &Event{Message: "out2", Kind: "stdout", Delay: 5},
- &Event{Message: "err1", Kind: "stderr", Delay: 5},
+ {Message: "out1", Kind: "stdout", Delay: 5},
+ {Message: "out2", Kind: "stdout", Delay: 5},
+ {Message: "err1", Kind: "stderr", Delay: 5},
}
delayCalledN := 0
delay = func(d time.Duration) {
- delayCalledN += 1
+ delayCalledN++
if d != 5 {
t.Errorf("delay func got unexpected value: %v", d)
}
@@ -78,8 +78,8 @@ func TestClient_Compile(t *testing.T) {
wantResp := &Response{
Errors: "",
Events: []*Event{
- &Event{Message: "test1", Kind: "stdout", Delay: 0},
- &Event{Message: "test2", Kind: "stdout", Delay: 2},
+ {Message: "test1", Kind: "stdout", Delay: 0},
+ {Message: "test2", Kind: "stdout", Delay: 2},
},
}
View
@@ -28,6 +28,7 @@ type Client struct {
Stderr io.Writer
}
+// Run runs code on connected go playground websocket server.
func (c *Client) Run(code string) error {
stdout, stderr := c.Stdout, c.Stderr
if stdout == nil {

0 comments on commit 73898f8

Please sign in to comment.