This isn't working for me. I get: C:\Users\swah\docs>gr TEST panic: Given path should be anchored at / goroutine 1 [running]: main.NewIgnorer(0xc08005bcf0, 0x29, 0x0, 0x0, 0x140110, ...) /Users/piranha/dev/go/src/goreplace/ignore.go:32 +0xa4 main.main() /Users/piranha/dev/go/src/goreplace/goreplace.go:62 +0x1b7 goroutine 2 [runnable]: [edit] New version is working!
Go Replace - simple and fast search and replace tool for command line
21–30 of 64 posts
Re: Go Replace - simple and fast search and replace tool for command line
#221. You've imported droundy/goopt, wsxiaoys/terminal really easily. The first provides option-parsing, and the second provides helpers for emitting ANSI escape codes.
2. Practically everything is overloaded. You can == to strcmp(), + to concatenate strings.
3. path/filepath gives you some nice goodies for path manipulation. But you have to deal with the fallouts of making naive assumptions like whether or not to recurse symlinks (why isn't this a flag in filepath.Walk?). This has resulted in ugliness in your walkFunc callback.
4. You have been able to abstract quite a bit without using Java-like factories, although your inconsistent error passing has me somewhat confused.
5. Since it's so strongly typed and there are no raw pointers, it's not going to be hard to debug at all.
Overall, I'd say Go is an effective language. But not beautiful, or novel in the slightest. It resembles Algol-68 (yes, a 1968 language) quite strongly, and I don't think it will drive compiler technology. Their syntax is specifically engineered to be parseable quickly (and hence super-fast AOT compilation): what the final program looks like is secondary concern. I'm not sure I see the appeal.
[edit: clarified that the note on compiler technology was an opinion]
Re: Go Replace - simple and fast search and replace tool for command line
#23This isn't working for me. I get: C:\Users\swah\docs>gr TEST panic: Given path should be anchored at / goroutine 1 [running]: main.NewIgnorer(0xc08005bcf0, 0x29, 0x0, 0x0, 0x140110, ...) /Users/piranha/dev/go/src/goreplace/ignore.go:32 +0xa4 main.main() /Users/piranha/dev/go/src/goreplace/goreplace.go:62 +0x1b7 goroutine 2 [runnable]: [edit] New version is working!
Re: Go Replace - simple and fast search and replace tool for command line
#24I really like Facebook's codemod.py for stuff like that: https://github.com/facebook/codemod It has something like automatic and manual modes, so you can check (and fix) every diff during the replacement
Well you see... It's in Python, which breaks the deal for me (I despise slow startup). But interactive mode sounds interesting, that's something I'll consider implementing.
Re: Go Replace - simple and fast search and replace tool for command line
#25This isn't working for me. I get: C:\Users\swah\docs>gr TEST panic: Given path should be anchored at / goroutine 1 [running]: main.NewIgnorer(0xc08005bcf0, 0x29, 0x0, 0x0, 0x140110, ...) /Users/piranha/dev/go/src/goreplace/ignore.go:32 +0xa4 main.main() /Users/piranha/dev/go/src/goreplace/goreplace.go:62 +0x1b7 goroutine 2 [runnable]: [edit] New version is working!
Should be fixed, can you download new version please?
←[0;32;49mRS\terms.tex
←[0m←[1;39;49m←[0;33;49m25:←[0m ←[0;39;43mOEM←[0m & \\ \hlineRe: Go Replace - simple and fast search and replace tool for command line
#26Okay, so what I learnt from this: 1. You've imported droundy/goopt, wsxiaoys/terminal really easily. The first provides option-parsing, and the second provides helpers for emitting ANSI escape codes. 2. Practically everything is overloaded. You can == to strcmp(), + to concatenate strings. 3. path/filepath gives you some nice goodies for path manipulation. But you have to deal with the fallouts of making naive assump…
Where do they say anything of the kind?
Re: Go Replace - simple and fast search and replace tool for command line
#27Okay, so what I learnt from this: 1. You've imported droundy/goopt, wsxiaoys/terminal really easily. The first provides option-parsing, and the second provides helpers for emitting ANSI escape codes. 2. Practically everything is overloaded. You can == to strcmp(), + to concatenate strings. 3. path/filepath gives you some nice goodies for path manipulation. But you have to deal with the fallouts of making naive assump…
That was my first somewhat big program in Go plus coming from Python made a bit of hustle here. I still believe exceptions to be much better than this error-returning. :\ Never learned to do it nicely. :\
> Overall, I'd say Go is an effective language. But not beautiful, or novel in the slightest.
Yes, this is more or less my feelings nowadays. It's good for certain cases and if I ever need something fast, I'll use Go and not C.
> I'm not sure I see the appeal.
There is some. It's still much simpler than C (GC + stricter compiler), plus it has goroutines (not much in this app, though), plus interfaces are really wonderful (you don't need to declare that you implement interface, just implement it and you're done).
Re: Go Replace - simple and fast search and replace tool for command line
#28Wow, it's super fast AND the output looks great. Good job, piranha! Copied to /usr/bin, I will use this a lot.
If you're the only user on your box, you can just create ~/bin and some distributions will automatically add it to your personal PATH. That way you don't lose track of what you've copied into /usr/bin, leaving it to be maintained by packages.
Re: Go Replace - simple and fast search and replace tool for command line
#29Earlier quoted context omitted.
Should be fixed, can you download new version please?
Working! Do you use colors? They don't work the same in DOS, I believe. I'm seeing some escape sequences. ←[0;32;49mRS\terms.tex ←[0m←[1;39;49m←[0;33;49m25:←[0m ←[0;39;43mOEM←[0m & \\ \hline
Re: Go Replace - simple and fast search and replace tool for command line
#30find ~/my/docs/ -type f -name '*.txt' -exec sed -i.bak 's/inheritance/composition/g' {} + This will search all files ending in `.txt` and will exec `sed 's/inheritance/composition/g'` on it. Sed modifies files in-place and saves a backup file with .bak extension (-i.bak) and is called the minimum necessary times (-exec +). My best advice to someone using the command line is to learn `find` + `xargs` or, even better,…
Compare with "gr what-is-it -r here-you-go". I do not have to remember all that argument hell.