Skip to content

Commit

Permalink
use New instead of NewRingBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Jun 4, 2019
1 parent b48fc22 commit c0c26dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example_test.go
Expand Up @@ -3,7 +3,7 @@ package ringbuffer
import "fmt"

func ExampleRingBuffer() {
rb := NewRingBuffer(1024)
rb := New(1024)
rb.Write([]byte("abcd"))
fmt.Println(rb.Length())
fmt.Println(rb.Free())
Expand Down
4 changes: 2 additions & 2 deletions ring_buffer.go
Expand Up @@ -25,8 +25,8 @@ type RingBuffer struct {
mu sync.Mutex
}

// NewRingBuffer returns a new RingBuffer whose buffer has the given size.
func NewRingBuffer(size int) *RingBuffer {
// New returns a new RingBuffer whose buffer has the given size.
func New(size int) *RingBuffer {
return &RingBuffer{
buf: make([]byte, size),
size: size,
Expand Down
4 changes: 2 additions & 2 deletions ring_buffer_test.go
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestRingBuffer_Write(t *testing.T) {
rb := NewRingBuffer(64)
rb := New(64)

// check empty or full
if !rb.IsEmpty() {
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestRingBuffer_Write(t *testing.T) {
}

func TestRingBuffer_Read(t *testing.T) {
rb := NewRingBuffer(64)
rb := New(64)

// check empty or full
if !rb.IsEmpty() {
Expand Down

0 comments on commit c0c26dd

Please sign in to comment.