Go언어 문자열 바꾸는 방법입니다.
Strings.Replace를 사용하면 됩니다.
package main
import (
"fmt"
"strings"
)
func main() {
str := "치환할문자열"
fmt.Println(strings.Replace(str, "치환할", "치환된", -1))
}
Go언어 문자열 바꾸는 방법입니다.
Strings.Replace를 사용하면 됩니다.
package main
import (
"fmt"
"strings"
)
func main() {
str := "치환할문자열"
fmt.Println(strings.Replace(str, "치환할", "치환된", -1))
}
윈도우에서 Go언어로 개발할 때 Avast를 백신으로 사용하고 있다면 잦은 실행파일을 빌드할 때 마다 검사 경고가뜹니다.
디버깅이나 실행버튼을 누를때마다 이런 일이 일어나기 때문에 굉장히 귀찮고 소리도 무척 거슬립니다.
Avast의 CyberCapture 기능을 비할성화하면 이 문제가 사라집니다.
물론 보안상 조금 더 위험해집니다.
작업이 끝나면 원래대로 설정을 바꿔 놓을 수 있습니다.
When developing a Golang application in Windows, how to disable the alert message.
If you develop an application with Golang in the environment which use Avast antivirus for Antivirus solution then you may frequently see alert message from Avast antivirus. for the purpose of removing the alert message.
Solution. You can disable the CyberCapture in your Avast configuration.
R에 설치된 오래된 패키지를 업데이트하는 방법입니다.
# 업데이트가 가능한 패키지 목록 확인하기
old.packages()
# 전체 패키지를 업데이트하기
update.packages()
# 안 물어보고 전체 패키지 업데이트하기
update.packages(ask = FALSE)
# 특정한 패키지만 업데이트하기
install.packages("plotly")
쉘스크립트(shell script)로도 If elif 를 사용할 수 있습니다.
가끔 쓰기 때문에 기억이 잘 나지 않아서 말이지요.
그리고 case 구문을 지원하기 때문에 여러 조건을 확인해야 하는 것도 가능하지만
case문은 가독성이 너무 떨어지기 때문에 거의 사용하지 않습니다.
어쨌든 shell script (bash 기준)에서 if, elif, else 구문은 이렇게 씁니다.
#!/bin/bash
a="1"
if [[ $a == "1" ]]; then
echo "a is 1"
elif [[ $a == "2" ]]; then
echo "a is 2"
elif [[ $a == "3" ]]; then
echo "a is 3"
elif [[ $a == "4" ]]; then
echo "a is 4"
else
echo "a is not 1, 2, 3, or 4"
fi
리눅스에서 fullname, FQDN 이름을 알아내는 방법입니다.
여러가지 방법이 있지만 hostname 명령어를 사용하는 것이 가장 쉽습니다.
hostname -A
주의할 것은 반드시 -A로 A가 대문자여야 하는 것입니다.
소문자로 쓰면 안되는 경우가 있으므로 주의하세요.