This repository contains the code examples for the book The Power of Go: Tools, by John Arundel.
bitfield / tpg-tools2 Goto Github PK
View Code? Open in Web Editor NEWCode examples from the book 'The Power of Go: Tools'
License: MIT License
Code examples from the book 'The Power of Go: Tools'
License: MIT License
This repository contains the code examples for the book The Power of Go: Tools, by John Arundel.
As the title suggests.. why does the test.txtar file exist?
Here is the Main
function for match:
func Main() int {
m, err := NewMatcher(
WithSearchTextFromArgs(os.Args[1:]),
)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
m.PrintMatchingLines()
return 0
}
Let's remove the ability to process arguments
func Main() int {
m, err := NewMatcher()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
m.PrintMatchingLines()
return 0
}
Executing the tests will still pass.
Let's also modify matches_lines_from_stdin.txtar
to add one additional line that should match
stdin three_matching_lines.txt
exec match MAGIC
stdout -count=1 '^this line is MAGIC\n'
stdout -count=1 '^MAGIC is also on this line\n'
stdout -count=1 '^and MAGIC is here too\n'
-- three_matching_lines.txt --
this won't match
this line is MAGIC
MAGIC is also on this line
but not this one
and MAGIC is here too
MAGIC is a lie
Tests still pass, even though we haven't added a stdout
directive to match the new line.
Hi @bitfield,
Is this repo intended to replace the https://github.com/bitfield/tpg-tools repo, or is this one for a follow-up edition of the book?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.