Last active
October 29, 2019 10:30
-
-
Save cwansart/8cd14252a66cafed105b60836ea73fba to your computer and use it in GitHub Desktop.
This file contains 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 cmd | |
import ( | |
"strings" | |
) | |
var usageHintMap = map[string]string{ | |
"bash": `# Run this command to configure your shell: | |
# eval $(minikube %placeholder docker-env) | |
`, | |
"fish": `# Run this command to configure your shell: | |
# eval (minikube %placeholder docker-env) | |
`, | |
"powershell": `# Run this command to configure your shell: | |
# & minikube docker-env %placeholder | Invoke-Expression | |
`, | |
"cmd": `REM Run this command to configure your shell: | |
REM @FOR /f "tokens=*" %i IN ('minikube %placeholder docker-env') DO @%i | |
`, | |
"emacs": `;; Run this command to configure your shell: | |
;; (with-temp-buffer (shell-command "minikube %placeholder docker-env" (current-buffer)) (eval-buffer)) | |
`, | |
} | |
func generateUsageHint(userShell string, parameters map[string]) string { | |
hint, ok := strings.replace(usageHintMap[userShell], "%placeholder", parameters["p"], 1) | |
if !ok { | |
return strings.Replace(usageHintMap["bash"], "%placeholder", parameters["p"], 1) | |
} | |
return hint | |
} |
Whoops. ;) Typo
Stell dir vor, das zweite return ist nicht da.
replace muss groß geschrieben werden und gibt nur ein wert zurück. den solltests du dann returnen :D
Okay, hab's angepasst.
gib das was in zeile 28 steht zurück. Replace gitb nur ein wert zurück https://golang.org/pkg/strings/#Replace
klein geschriebene funktionen sind private und groß sind public. deswegen kannst du keine kleingeschrieben funktionen auf "externe" objekte aufrufen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wie hast du 2 return statements hintereinander bekommen?