aisola / go-coreutils Goto Github PK
View Code? Open in Web Editor NEWAn attempt at a Go implementation of the GNU Coreutils.
License: GNU General Public License v3.0
An attempt at a Go implementation of the GNU Coreutils.
License: GNU General Public License v3.0
Hi... cool project.
I was just checking it out and noticed the binaries are anywhere from 2.3M to 3.6M
Perhaps this would benefit from a design similar to busybox where there is just a single binary with symlinks to it and it knows which command to run via argv[0].
... either that or wait for Go to get the binary size under control.
The flag
package in golang doesn't support combination of short flags.
e.g. in GNU style, -help
means -h -e -l -p
, and -n1
means -n=1
.
But in Go -help
means --help
, and -n1
means --n1
. Without a proper GNU style flag parser, there's no easy way to support things like tail -n10
.
Here's a short list of packages I googled that do GNU style flag parsing:
I'll be happy to provide some PR if any of the packages are accepted as replacement.
Running wc.go
on a large file destroys my 8GB of RAM. On a 550MB file it works fine, but on a 3.3GB file my computer freezes.
Are these utilities going to have the same flags as normal? I just ask because I skimmed cat.go (as an example) and I didn't see all the normal flags I'd expect.
Using runtime.GOARCH
will return the architecture used to compile the binary, not the architecture of the system at runtime.
As described in 0c29544 the output of this mkdir implementation shows only the path to the deepest folder, whereas gnu mkdir list all intermediary folders that were created.
This happens when --verbose and --parents options are combined.
Is it necessary for this implementation to provide the same output as the gnu version?
If we link all programs into the same binary, then differentiate with symlink or first arg, it might make the resulting binary managable.
The commands cat, groups, logname, and whoami all fail with this error
# _/home/e5ten/github/go-coreutils/<command name>
runtime/cgo(.text): relocation target pthread_mutex_lock not defined
runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
runtime/cgo(.text): relocation target pthread_mutex_lock not defined
runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
runtime/cgo(.text): relocation target pthread_mutex_lock not defined
runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
runtime/cgo(.text): relocation target pthread_mutex_lock not defined
runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
runtime/cgo(.text): undefined: "pthread_mutex_lock"
runtime/cgo(.text): undefined: "pthread_mutex_unlock"
runtime/cgo(.text): undefined: "pthread_mutex_lock"
runtime/cgo(.text): undefined: "pthread_mutex_unlock"
runtime/cgo(.text): undefined: "pthread_mutex_lock"
runtime/cgo(.text): undefined: "pthread_mutex_unlock"
runtime/cgo(.text): undefined: "pthread_mutex_lock"
runtime/cgo(.text): undefined: "pthread_mutex_unlock"```
this made me sad today
disk_usage() {
# normalize du across systems
case $(uname -s) in
Linux)
DU="du -sb"
;;
FreeBSD)
DU="du -s -A -B 1"
;;
Darwin | DragonFly)
DU="du"
;;
esac
$DU "$1" | awk "{print \$1}"
}
maybe this project can make a go-du
that's the same everywhere :)
The mv command silently fails when moving a file across devices.
os.Rename doesn't work across devices. It returns a *os.LinkError with "invalid cross-device link".
Might be worth looking at https://github.com/termie/go-shutil as a starting point. It only does copy though, not move.
You will probably save alot of binary size when you implement symlink-style executables like busybox
does. There is one big executable with all the commands inside and the symlinks point to the busybox
executable. When the symlink is executed os.Argv[0]
is read and checked and dispatched to the correct command. (https://www.busybox.net)
You could do this in golang very easy:
package main
import (
"fmt"
"os"
"path"
)
func func1() {
fmt.Printf("Hello world from func1(args: %+v)\n", os.Args)
}
func main() {
if path.Base(os.Args[0]) == "func1" {
func1()
}
}
$ go build main.go
$ ln -s main func1
$ ./func1 1234 5678 9012
Hello world from func1(args: [./func1 1234 5678 9012])
Its just an idea :-)
I have implemented split and tsort for Rust coreutils. As a way of exercising Go lang. I will implement these commands
https://github.com/uutils/coreutils
I have a nice project for testing these commands. Go-version will be tested, too
https://github.com/akiradeveloper/rust-split
https://github.com/akiradeveloper/rust-tsort
I did ls
on /root
from my user expecting that the command would show "Permission Denied"
. Instead it prints "No such file or directory"
.
The coreutils ls command indicates that I do not have permission to list /root
folder by printing "Permission Denied"
.
I am new to Go. And am looking at this project in order to learn.
Could someone please fix it.
For instance, the paragraph (I have no clue what it means):
ことしで65回目を迎える年末恒例のNHK紅白歌合戦に出場する歌手が決まり、26日、発表されました。ことしの紅白歌合戦は、初出場の5組を含め、紅白合わせて51組が出場します。東京・渋谷のNHK放送センターでは、初出場の方たちが記者会見で意気込みを語りました。出場歌手の一覧のほか、2組の出場歌手の会見動画も併せてご覧下さい。
According to GNU's wc, it should print 0 new lines, 1 word, 161 chars, 483 bytes, and a line-length of 322. Instead, it prints 0 l, 1 w, 483 m, 483 c, 483 L.
Check out this webpage detailing Cobra, and how it would apply to this project.
http://blog.gopheracademy.com/advent-2014/introducing-cobra/
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.