acm

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 2 Imported by: 0

README

ACM Mode Utils

Usage

Mock Stdin
package example

import "github.com/jtr109/lcutils/acm"

func main() {
	input := "-10\n20\n5\n10\n3\n"
	mockedStdin, _ := acm.MockStdin()
	defer mockedStdin.Close()
	mockedStdin.Write(input)

	output := readStdin() // []int{-10, 20, 5, 10, 3}
}
Mock Stdout
import "github.com/jtr109/lcutils/acm"

func main() {
	mockedStdout, _ := acm.MockStdout()
	defer mockedStdout.Close()

	content := "Hello, playground"
	fmt.Print(content)

	out, _ := mockedStdout.Read() // "Hello, playground"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockedStdin

type MockedStdin struct {
	// contains filtered or unexported fields
}

func MockStdin

func MockStdin() (*MockedStdin, error)

func (*MockedStdin) Close

func (ms *MockedStdin) Close() (err error)

func (*MockedStdin) Write

func (ms *MockedStdin) Write(input string) error

type MockedStdout

type MockedStdout struct {
	// contains filtered or unexported fields
}

func MockStdout

func MockStdout() (*MockedStdout, error)

func (*MockedStdout) Close

func (ms *MockedStdout) Close() (err error)

func (*MockedStdout) Read

func (ms *MockedStdout) Read() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL