You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: storage.go
    path of file: ./repos/im_service/ims
    
    the code of the file until where you have to start completion: /**
 * Copyright (c) 2014-2015, GoBelieve     
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public L
    
func (storage *Storage) SaveSyncMessage(emsg *EMessage) error {
	storage.mutex.Lock()
	defer storage.mutex.Unlock()

	n := storage.getBlockNO(emsg.msgid)
	o := storage.getBlockOffset(emsg.msgid)

	if n < storage.block_NO || (n - storage.block_NO) > 1 {
		log.Warning("skip msg:", emsg.msgid)
		return nil
	}

	if (n - storage.block_NO) == 1 {
		storage.file.Close()
		storage.openWriteFile(n)
	}

	offset, err := storage.file.Seek(0, os.SEEK_END)
	if err != nil {
		log.Fatalln(err)
	}

	if o < int(offset) {
		log.Warning("skip msg:", emsg.msgid)
		return nil
	} else if o > int(offset) {
		log.Warning("write padding:", o - int(offset))
		padding := make([]byte, o - int(offset))
		_, err = storage.file.Write(padding)
		if err != nil {
			log.Fatal("file write:", err)
		}
	}

	storage.WriteMessage(storage.file, emsg.msg)
	storage.execMessage(emsg.msg, emsg.msgid)
	log.Info("save sync message:", emsg.msgid)
	return nil
}