How to join the elements of two slices of bytes into a string Go

1 Answer

0 votes
package main 
  
import ( 
    "bytes"
    "fmt"
) 
  
func main() { 
    slice := [][]byte{[]byte("go"),  
                      []byte("java"),  
                      []byte("php")} 
    sep := []byte(" : ") 
  

    s := bytes.Join(slice, sep) 
  
    fmt.Printf("%s", s) 
  
} 
  
   
  
    
/*
run:
     
go : java : php
 
*/

 



answered Aug 18, 2020 by avibootz

Related questions

1 answer 119 views
119 views asked Aug 18, 2020 by avibootz
2 answers 211 views
211 views asked Aug 18, 2020 by avibootz
1 answer 79 views
1 answer 166 views
1 answer 170 views
...