Go
å æ¥ãèªåã®ä½ã£ã¦ãããã¤ããªã¨ãã£ã¿bedãhomebrew/coreã«å ¥ã£ããã¨ããå ±åãã¾ããã ãã®å¾ãã³ã¼ããçºãã¦ããã¨è²ã ã¨ç´ãããã¨ãããåºã¦ãããã欲ããæ©è½ã®å®è£ ã¤ã¡ã¼ã¸ã沸ããããã¦ãã¾ãæ´»çºã«éçºããããã«ãªãã¾ããã ä»ã§ããããªâ¦
æ°å¹´åã«ã趣å³ã§bedã¨ãããã¤ããªã¨ãã£ã¿ãä½ã£ããã¨ãããã¾ããã å½æã¯ã¡ã¢ãªã¼ã«ä¹ããªããããªå¤§ããªãã¡ã¤ã«ãæç»ããããç·¨éã§ããããã«ãããã¸ãã¯ãèããã®ã楽ãããã¨ã¦ãç±ä¸ãã¦ãã¾ããã itchyny.hatenablog.com åºæ¬çãªæ©è½ããâ¦
ãã®è¨äºã¯Mackerel Advent Calendar 2023ã®20æ¥ç®ã§ãã æ¨æ¥ã¯sfujiwaraããã§ããã å æ¥15æ¥ç®ã®è¨äºã§ãç§ãä½ã£ãRustã¯ã©ã¤ã¢ã³ãmackerel-client-rsã®è¨è¨ã«ã¤ãã¦ãç´¹ä»ãã¾ããã itchyny.hatenablog.com ã¯ã©ã¤ã¢ã³ãã®è¨è¨ã«ã¤ãã¦è²ã ã¨ãç´¹ä»â¦
ä»å¹´ã®å¤ã«Goè¨èªã«ä»¥ä¸ã®ãããªãããã¼ã¶ã«ãåºãã¦ããã®ã§ããããããå ã»ã©æ¿èªããã¾ãããæ¨æºããã±ã¼ã¸ã®é¢æ°è¿½å ã«ãªãã¾ãã proposal: bytes, strings: add ContainsFunc · Issue #54386 · golang/go · GitHub Goè¨èªã®stringsããã±ã¼ã¸ã¨byteâ¦
JSONãYAMLã«å¤æããã³ãã³ã json2yaml ããGoè¨èªã§ä½ã£ã¦ã¿ã¾ããã ä»ã®è¨èªãå«ããã¨åããããªã³ãã³ãã©ã¤ã³ãã¼ã«ã¯ç¡æ°ã«ä½ããã¦ãã¾ããã Goã®ã©ã¤ãã©ãªã¨ãã¦çµã¿è¾¼ã¿ããã£ãã¨ããã®ãæåã®ã¢ããã¼ã·ã§ã³ã§ãã ã¾ããJSONãã¹ããªã¼ãâ¦
Go 1.18 ããªãªã¼ã¹ããã¦ä¸ãæç¨çµã¡ã¾ããã å æ¥ go run ã (go generateçµç±ã§) 使ã£ã¦ããã³ã¼ãã®æåãè¦ã¦ããããã¢ã¸ã¥ã¼ã«å¨ãã®æåã Go 1.17 ã¨ç°ãªããã¨ã«æ°ãä»ãã¾ããã Go 1.16 以éãgo get ã go mod tidy ã®ãããªä¸é¨ã®ã³ãã³ããâ¦
å¼ç¤¾ã®ã¨ããGoãããã¯ãã§Go 1.14ãã1.16ã¸ã¢ãããã¼ãããã¨ãããããã°ã©ã ã®æåãå¤ããåé¡ãçºçãã¾ãã *1ã ããã¥ã¡ã³ãã«æ¸ããã¦ããªã strconv.ParseFloat ã®æåã®å¤æ´ãè¸ãã§ãã¾ã£ãã®ã§ãã package main import ( "fmt" "strconv" )â¦
Goè¨èªã§æ¸ãããorderedmapã¨ãããµã¼ããã¼ãã£ããã±ã¼ã¸ãããã¾ãã github.com Goã®mapã«ã¯é åºããªããJSONããã³ã¼ãããã¨é åºã失ããããããã¨ã³ã³ã¼ãããã¨ãªãã¸ã§ã¯ãã®ãã¼ã®é åºã«ã½ã¼ãããã¾ãã ããã«å°ã人ã¯ããããããããã§ãé â¦
gojqã¯Goã§å®è£ ãããjqã³ãã³ãããã³ã©ã¤ãã©ãªã§ãã2019å¹´ã®4æããéçºãå§ãã¦ãç¾å¨ãæ§ã ãªæ¹åãè¡ã£ã¦ãã¾ãã ããã¾ã§gojqã®Homebrew formulaã¯itchyny/tapããé ä¿¡ãã¦ãã¾ãããããã®ãã³å ¬å¼ã®homebrew/coreã«å ¥ãã¾ããã ããã«ããã次ã®â¦
ä¸å¹´åããã¡ã¤ã«ãã¨ãã£ã¿ã¼ã§ä¸æ¬ãªãã¼ã ããmmvã³ãã³ããä½ãã¾ããã itchyny.hatenablog.com github.com mmvã¯ãªãã¼ã ã®ä¾åé¢ä¿ã解æãã¦é çªã決å®ãã¾ããä¾ãã° a => b b => c ã¨ãããªãã¼ã ãæç´ã«ä¸ããå®è¡ããã¨ããã¡ã¤ã«bãæ¶ãã¦ãã¾â¦
Perlã«ã¯Regexp::Assembleã¨ãã便å©ãªã©ã¤ãã©ãªãããã¾ãã è¤æ°ã®æ£è¦è¡¨ç¾ãåãåãããããã®ããããã«ãããããæ£è¦è¡¨ç¾ãæ§ç¯ããããã®ã©ã¤ãã©ãªã§ãã my $ra = Regexp::Assemble->new; $ra->add( 'ab+c' ); $ra->add( 'ab+\\d*\\s+c' ); $ra->â¦
Goè¨èªã§strftimeã»strptimeç¸å½ã®é¢æ°ãæä¾ããã©ã¤ãã©ãªãå®è£ ãã¾ããã t, _ := timefmt.Parse("2020/07/24 09:07:29", "%Y/%m/%d %H:%M:%S") fmt.Println(t) // 2020-07-24 09:07:29 +0000 UTC str := timefmt.Format(t, "%Y/%m/%d %H:%M:%S") fmt.Prâ¦
jqã¯JSONãçµãè¾¼ããã¼ã«ã§ãããå®ã¯ãã£ãã¨ããããã°ã©ãã³ã°è¨èªã§ãã ç®è¡æ¼ç®åãè«çæ¼ç®åãåå²æ§æãtryã»catchãããã¦é¢æ°å®ç¾©ããããã«ã¼ãã¯å帰é¢æ°ã§å®è£ ãã¾ãã åã« .foo ã¨ã .[0] ã¨ãã§JSONã辿ãã ãã®ãã¼ã«ã ã¨æããã¦ããæ¹â¦
ãã¡ã¤ã«ãä¸æ¬ã§ãªãã¼ã ããããã¨ã¯ããã¾ããããç§ã¯ããã¾ããã¨ãããã¨ã§ä½ãã¾ããã ã¤ã³ã¹ãã¼ã«ã¯Homebrew brew install itchyny/tap/mmv ã¾ãã¯ä»¥ä¸ã®ã³ãã³ãã§ã§ãã¾ãã go get github.com/itchyny/mmv/cmd/mmv ã¹ã¯ãªã¼ã³ã·ã§ããã§ã¯vimãâ¦
å¼ç¤¾ã§ã¯GitHub Enterprise (以ä¸GHE) ããGitHubã¸ã®ç§»è¡ãé²ãã§ãã¾ããä»å¹´é ã®ãã©ã³æ¹å¤ãGitHub ConnectãActionsãAppsã®å å®ãªã©GitHubã®æ©è½å¼·åãå¾æ¼ãã¨ãªãã¾ãããGHEã®ã¡ã³ããã³ã¹ã³ã¹ããå¾ã ã«éè·ã«ãªã£ã¦ãã¦ãã¾ããã ãªãã¸ããªã移â¦
jqã¯ã¨ã¦ã便å©ãªã³ãã³ãã§ãã JSONãè¿ãAPIãå®è£ ããã¨ãããSaaSã®APIããç¹å®ã®æ å ±ãæãåºãã¦ã·ã§ã«å¤æ°ã«ä»£å ¥ããã¨ããªã©ãwebéçºãéç¨ã«ã¯æ¬ ãããªããã¼ã«ã¨ãªã£ã¦ãã¾ãã ããããç§ã«ã¨ã£ã¦jqã®ã¯ã¨ãªãä¸çºã§æ¸ãã®ã¯å®¹æã§ã¯ãªããæãâ¦
joã¨ããJSONãçµã¿ç«ã¦ãã³ãã³ãããã£ã¦ãããã¯2016å¹´ãããã便å©ãªCLIãã¼ã«ãªã®ã§ãããæ¨æ¥æ¥ã«æãç«ã£ã¦Goå®è£ ãä½ãã¾ããã go get github.com/itchyny/gojo/cmd/gojo brewã§ãã¤ã³ã¹ãã¼ã«ã§ãã¾ãã brew install itchyny/tap/gojo 使ãæ¹ã¯ãâ¦
Goè¨èªã®REPLãgoreã®0.4.0ããªãªã¼ã¹ãã¾ããã id:motemenããã«é£çµ¡ãã¨ã£ã¦ãgoreã®ã³ããã権ãããã ãã¾ããã æåã¯pull requestãæºã¾ã£ã¦ããã®ã§çä»ãã¦ãç´°ãããã°ä¿®æ£ãªã©ãè¡ãã¾ããã ãã°ãã触ã£ã¦ããã¨æ £ãã¦ããã®ã§ãæ°æ©è½ãå®è£ â¦
Mackerelã®ã°ã©ãã端æ«ã§è¦ããããããªã¨æã£ãã®ã§ä½ã£ã¦ã¿ã¾ããã github.com 使ãæ¹ $ go get github.com/itchyny/mkrg/cmd/mkrg $ mkrg ã³ãã³ããå©ãã¨ããã®ãã¹ãã®ã¡ããªãã¯ãåã£ã¦ãã¦ã°ã©ãã表示ãã¾ãã ä½ãèããã«ã³ãã³ããå©ãã°ãã·â¦
ãã¤ããªã¨ãã£ã¿ãä½ãã¾ããã ã¤ã³ã¹ãã¼ã«ã¯Homebrew brew install itchyny/tap/bed ã¾ãã¯ä»¥ä¸ã®ã³ãã³ãã§ã§ãã¾ãã go get github.com/itchyny/bed/cmd/bed ãªãä½ã£ãã®ã ç§ã¯æãããã¡ã¤ã«ãã©ã¼ãããã«èå³ããããç»åãã¡ã¤ã«ãPDFãã¡ã¤ã«â¦
ã«ã¼ãã«ã®ãã©ã¡ã¼ã¿ãå¼ãããè¨å®ãããããæã«ä¾¿å©ãªã®ã sysctl ã³ãã³ãã§ãã $ sysctl kern.ostype kern.ostype: Darwin ãã®ã³ãã³ãã®ã·ã¹ãã ã³ã¼ã«ãGoè¨èªããå©ãã¦ãOSã®ç¨®é¡ãå¼ãã¦ã¿ã¾ãããã func main() { ret, _ := syscall.Sysctl("â¦
Reader interface ã® Read é¢æ°ã¯ãã©ã®ã¿ã¤ãã³ã°ã§ io.EOF ãè¿ãã®ã§ããããã ã¾ã㯠strings.Reader ã§è¦ã¦ã¿ã¾ãããã package main import ( "fmt" "strings" ) func main() { r := strings.NewReader("example\n") for { var b [1]byte n, err := â¦
volumeã³ãã³ããä½ãã¾ããã é³éã®èª¿æ´ã£ã¦ã³ãã³ãããã©ããããã ããããã¼ã¿ãã«ãªå½¢ã§ã³ãã³ãã©ã¤ã³ãã¼ã«ãããã°ä¾¿å©ãªã®ã§ã¯â¦ ã¨æã£ãã®ã§ä½ãã¾ããã macOSã¨Ubuntuã§åä½ç¢ºèªããã¦ãã¾ãã ã¤ã³ã¹ãã¼ã« go get github.com/itchyny/volumeâ¦
fillinã¨ããã³ãã³ãã©ã¤ã³ãã¼ã«ãä½æãã¾ããã ã³ãã³ãã®ä¸é¨ãå¤æ°åãã¦ãå¥ã®å±¥æ´ã«ä¿åãã¦ããããã¼ã«ã§ãã ã¹ãã¼ã¸ã³ã°ç°å¢ã¨æ¬çªç°å¢ã®ããã«ãåãã³ãã³ãã§è¤æ°ã®ç°å¢ãåãæ¿ããã®ã«ä¾¿å©ã§ãã zshã®æ¬ (ã¨ãã»ã³ã·ã£ã«ã½ããã¦ã§ã¢ã¬â¦
Goè¨èªã§base58ã³ãã³ããæ¸ãã¾ãããã³ãã³ãã©ã¤ã³ãã¼ã«ã ãã§ã¯ãªãã¦ãGoã®ããã±ã¼ã¸ã¨ãã¦ä½ã£ã¦ãã¾ãã github.com ä»äºã®é¢ä¿ã§base58ãæ±ããã¨ããããbase64ã³ãã³ãã®ããã«ç´ æ©ãã³ãã³ãã©ã¤ã³ã§å¤æã§ãããã¼ã«ã欲ãããªã£ãã®ã§ä½ãã¾â¦
è¿·è·¯ã§éã³ãããªã£ãã®ã§ä½ãã¾ãããGoã§æ¸ãã¦ãã¾ãã github.com Homebrewãã使ãã®æ¹ã¯ã次ã®ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ãã¦ãã ããã brew install itchyny/tap/maze ããã§ãªãæ¹ã¯ã次ã®ã³ãã³ãã§ãã«ããã¦ã¤ã³ã¹ãã¼ã«ãããã go get github.comâ¦
ãããã ã½ããã¦ã§ã¢ã®ä¸ã®ä¾åé¢ä¿ã«ã¤ã㦠æ£è¦è¡¨ç¾ã§æ½åºã§ãããã¨ã¨ãã®éç ã³ã¼ãã®ä¾åé¢ä¿ãæ½åºãããã¼ã« rexdep ãä½ãã¾ãã ã½ããã¦ã§ã¢ã®æ§é ãæ¦è¦³ããã«ã¯ ããªãã¯ã大ããªã½ããã¦ã§ã¢ãç®ã«ããæãä½ããã¾ããï¼ ãã¡ã¤ã«ãä½åãâ¦