티스토리 뷰
728x90
package main
import (
"os"
"strings"
"text/template"
)
func Format(s string, v interface{}) string {
t, b := new(template.Template), new(strings.Builder)
template.Must(t.Parse(s)).Execute(b, v)
result := b.String()
if result == "<no value>" {
return s
}
return result
}
func KeyValue(item string) (key, val string) {
splits := strings.Split(item, "=")
key = splits[0]
val = splits[1]
return
}
func Env() map[string]string {
data := os.Environ()
items := make(map[string]string)
for _, item := range data {
key, val := KeyValue(item)
items[key] = val
}
return items
}
func main() {
response := Format("{{ .asdf }}", Env())
println(response)
}
https://stackoverflow.com/questions/19612449/default-value-in-gos-method
https://stackoverflow.com/questions/19761393/why-does-go-have-typed-nil
https://gist.github.com/naveensrinivasan/5846791
728x90
'공부' 카테고리의 다른 글
[aws] s3 cp github action (workflow) (0) | 2022.08.31 |
---|---|
[MySQL] id 컬럼 데이터타입 INT? BIGINT? (0) | 2022.08.31 |
[aws] ECR docker login & pull (0) | 2022.08.23 |
Dockerfile': group id '1849965015' is too big ( > 2097151 ). Use STAR or POSIX extensions to overcome this limit (0) | 2022.08.22 |
[aws][s3] bucket lifecycle (0) | 2022.08.22 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 테슬라 리퍼럴 코드 혜택
- wlw
- 모델 Y 레퍼럴
- 테슬라
- COUNT
- 인스타그램
- 테슬라 레퍼럴 코드 확인
- 테슬라 레퍼럴 적용 확인
- 할인
- 테슬라 리퍼럴 코드
- 개리마커스
- Kluge
- 팔로워 수 세기
- 어떻게 능력을 보여줄 것인가?
- 테슬라 추천
- 모델y
- 테슬라 리퍼럴 코드 생성
- 유투브
- 메디파크 내과 전문의 의학박사 김영수
- 김달
- Bot
- 레퍼럴
- 연애학개론
- 책그림
- 클루지
- 테슬라 크레딧 사용
- 테슬라 레퍼럴
- follower
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함