Skip to content

Instantly share code, notes, and snippets.

@cwansart
Last active October 29, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwansart/8cd14252a66cafed105b60836ea73fba to your computer and use it in GitHub Desktop.
Save cwansart/8cd14252a66cafed105b60836ea73fba to your computer and use it in GitHub Desktop.
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
}
@max-weis
Copy link

wie hast du 2 return statements hintereinander bekommen?

@cwansart
Copy link
Author

Whoops. ;) Typo

@cwansart
Copy link
Author

Stell dir vor, das zweite return ist nicht da.

@max-weis
Copy link

replace muss groß geschrieben werden und gibt nur ein wert zurück. den solltests du dann returnen :D

@cwansart
Copy link
Author

Okay, hab's angepasst.

@max-weis
Copy link

gib das was in zeile 28 steht zurück. Replace gitb nur ein wert zurück https://golang.org/pkg/strings/#Replace

@max-weis
Copy link

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