浏览代码

Small tweaks to the code

Signed-off-by: Miek Gieben <miek@miek.nl>
Miek Gieben 5 年之前
父节点
当前提交
9132b485e3
共有 3 个文件被更改,包括 6 次插入9 次删除
  1. 3 3
      README.md
  2. 1 4
      example.go
  3. 2 2
      example_test.go

+ 3 - 3
README.md

@@ -2,12 +2,12 @@
 
 ## Name
 
-*example* - prints "example" on every query received.
+*example* - prints "example" on every query handled.
 
 ## Description
 
-The example plugin prints "example" on every query received. It serves as documentation for
-writing CoreDNS plugins.
+The example plugin prints "example" on every query that go handled by the server. It serves as
+documentation for writing CoreDNS plugins.
 
 ## Syntax
 

+ 1 - 4
example.go

@@ -61,12 +61,9 @@ func NewResponsePrinter(w dns.ResponseWriter) *ResponsePrinter {
 
 // WriteMsg calls the underlying ResponseWriter's WriteMsg method and prints "example" to standard output.
 func (r *ResponsePrinter) WriteMsg(res *dns.Msg) error {
-	fmt.Fprintln(out, ex)
+	fmt.Fprintln(out, "example")
 	return r.ResponseWriter.WriteMsg(res)
 }
 
 // Make out a reference to os.Stdout so we can easily overwrite it for testing.
 var out io.Writer = os.Stdout
-
-// What we will print.
-const ex = "example"

+ 2 - 2
example_test.go

@@ -29,7 +29,7 @@ func TestExample(t *testing.T) {
 
 	// Call our plugin directly, and check the result.
 	x.ServeDNS(ctx, rec, r)
-	if a := b.String(); a != ex+"\n" {
-		t.Errorf("Failed to print '%s', got %s", ex, a)
+	if a := b.String(); a != "example\n" {
+		t.Errorf("Failed to print '%s', got %s", example, a)
 	}
 }