This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// longestCommonPrefix returns the string in compares that has the longest common prefix with s | |
func longestCommonPrefix(s string, compares ...string) string { | |
var longestMatched int | |
var longestCmp string | |
maxLength := len(s) | |
for _, c := range compares { | |
cmpLen := len(c) | |
if cmpLen > maxLength { | |
cmpLen = maxLength | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ask_yes_no() { | |
local prompt="$1" | |
while true; do | |
read -p "$prompt [y/n]?" yn | |
case "$yn" in | |
[Yy]* ) return 0;; | |
[Nn]* ) return 1;; | |
* ) echo "Please answer y or n";; | |
esac | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"path" | |
"syscall" | |
) | |
// isMountPoint returns true if the given directory is a mountpoint | |
func isMountPoint(fileName string) (bool, error) { | |
dir := path.Clean(fileName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"errors" | |
"fmt" | |
"time" | |
"github.com/gammazero/workerpool" | |
) |
NewerOlder