通过TCP Golang发送多个文件-简单协议

I'm trying to build a simple protocol to send files over TCP in golang. After reading some stuff I decided to use GOB package to send a header with information about file being sent and then file in using raw socket. Between messages I'm using a delimiter ("/r/n") So the sendflow looks like that: Client(sends a file)(C) Server(S)

  • (C)Reading file metadata(filesize, filename, etc)
  • (C)Encoding file metadata into struct
  • (C)Intialize connection with server
  • (C)Send encoded gob
  • (S)Receive a gob and decode
  • (C)Send a delimiter
  • (S)Receive a delimiter
  • (C)Start sending file using buffer (1024)
  • (S)Start receiving file and saving to created file until size from header message will be exceeded.
  • (C)Send a delimiter
  • (S)Receive a delimiter
  • (C)Close connection

Hopefully I explained it well. A problem is that in my unittests when I'm checking checksums of file being transfered sometimes I have wrong files it looks like sometimes the delimiter is added also. My question is if my simple protocol does make sense, if not could someone give my some advices how to build it to be robust and reliable.

Thanks in advance!