반응형
package main
import (
"fmt"
"strings"
)
func main() {
var string_a string = "My super \nsweet \nstring has \nmany newline\n characters"
fmt.Println(string_a)
var string_b string = string_a
string_b = strings.Replace(string_b, "\n", "", -1)
fmt.Println(string_b)
}
또는
string_b = strings.Replace(string_b, "\r\n", "", -1)
|
참고
https://topherpedersen.blog/2020/02/03/how-to-strip-newline-characters-from-a-string-in-golang/
How to Strip Newline Characters from a String in Golang | topherpedersen.blog
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a b
topherpedersen.blog
https://gist.github.com/topherPedersen/a6d1f4f9a9e95852a3d1907b4e505625
반응형
'Web > GoLang' 카테고리의 다른 글
[golang] makefile , gomodule 에 대한 윈도우 사용 후기와 makefile 설정 리뷰 (0) | 2023.05.05 |
---|---|
[Grpc ] grpc k8s kubernetes 관련 내용 (0) | 2023.01.30 |
[golang] goland 에서 makefile 동작하기 (0) | 2023.01.10 |
[goland] 프로젝트 리파짓토리 복사 사용 (0) | 2023.01.10 |
[golang] invalid pseudo-version: preceding tag (v0.0.0) not found (0) | 2022.11.10 |
댓글