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 65 views
1 answer 143 views
143 views asked Aug 18, 2020 by avibootz
2 answers 251 views
251 views asked Aug 18, 2020 by avibootz
2 answers 242 views
242 views asked Sep 4, 2020 by avibootz
1 answer 157 views
157 views asked Aug 27, 2020 by avibootz
...