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: code.go
    path of file: ./repos/natpass/code/client/rule/code
    
    the code of the file until where you have to start completion: package code

import (
	"errors"
	"fmt"
	"net"
	"net/http"
	"sync"
	"time"

	"github.com/lwch/logging"
	"github.com/lwch/natpass/code/client/conn"
	"github.com/lwch/natpass/code/client/global"
	"github.com/lwch/natpass/code/client/ru
    
func (code *Code) new(conn *conn.Conn) (string, error) {
	id, err := runtime.UUID(16, "0123456789abcdef")
	if err != nil {
		logging.Error("failed to generate link_id for code-server: %s, err=%v",
			code.Name, err)
		return "", err
	}
	link := code.NewLink(id, code.cfg.Target, nil, conn).(*Workspace)
	conn.SendConnectReq(id, code.cfg)
	ch := conn.ChanRead(id)
	var repMsg *network.Msg
	for {
		var msg *network.Msg
		select {
		case msg = <-ch:
		case <-time.After(time.Minute):
			logging.Error("create code-server %s by rule %s failed, timtout", link.id, link.parent.Name)
			return "", errWaitingTimeout
		}
		if msg.GetXType() != network.Msg_connect_rep {
			conn.Requeue(id, msg)
			time.Sleep(code.readTimeout / 10)
			continue
		}
		rep := msg.GetCrep()
		if !rep.GetOk() {
			logging.Error("create code-server %s by rule %s failed, err=%s",
				link.id, link.parent.Name, rep.GetMsg())
			return "", errors.New(rep.GetMsg())
		}
		repMsg = msg
		break
	}
	logging.Info("create link %s for code-server rule [%s] from %s to %s",
		link.GetID(), code.cfg.Name,
		repMsg.GetTo(), repMsg.GetFrom())
	go link.localRead()
	return id, nil
}