func (d *DLConn) SetId(program, username string) error {

	id := fmt.Sprintf("%v:%v:%v:%v-%v", program, username, os.Getpid(), runtime.GOOS, runtime.GOARCH)

	dlp := Packet{
		Header: []byte(fmt.Sprintf("%s %s", cmdId, id)),
	}

	resp, err := d.sendPacket(dlp)
	if err != nil {
		return err
	}

	d.id = id

	// Like: ID DataLink 2014.269 :: DLPROTO:1.0 PACKETSIZE:512 WRITE
	if split := strings.Split(resp.header(), "::"); len(split) > 1 {
		for _, f := range strings.Split(split[1], " ") {
			switch {
			case f == "WRITE":
				d.writable = true
			case strings.HasPrefix(f, "PACKETSIZE:"):
				size, err := strconv.ParseInt(strings.Split(f, ":")[1], 10, 32)
				if err != nil {
					return fmt.Errorf("failed to parse packetsize: %v", err)
				}
				d.size = int(size)
			}
		}
	}

	return nil
}
// SetId sens an ID message to the remote connection and decodes the connection capabilities.
SetId sens an ID message to the remote connection and decodes the connection capabilities.
// SetId sens an ID message to the remote connection and decodes the connection capabilities .
func (d *DLConn) SetId(program, username string) error {
	id := fmt.Sprintf("%v:%v:%v:%v-%v", program, username, os.Getpid(), runtime.GOOS, runtime.GOARCH)
	dlp := Packet{
		Header: []byte(fmt.Sprintf("%s %s", cmdId, id)),
	}
	resp, err := d.sendPacket(dlp)
	if err != nil {
		return err
	}
	d.id = id
	if split := strings.Split(resp.header(), "::"); len(split) > 1 {
		for _, f := range strings.Split(split[1], " ") {
			switch {
			case f == "WRITE":
				d.writable = true
			case strings.HasPrefix(f, "PACKETSIZE:"):
				size, err := strconv.ParseInt(strings.Split(f, ":")[1], 10, 32)
				if err != nil {
					return fmt.Errorf("failed to parse packetsize: %v", err)
				}
				d.size = int(size)
			}
		}
	}
	return nil
}
func ( d * DLConn ) SetId ( program , username string ) error { id := fmt . Sprintf ( " " , program , username , os . Getpid ( ) , runtime . GOOS , runtime . GOARCH ) dlp := Packet { Header : [ ] byte ( fmt . Sprintf ( " " , cmdId , id ) ) , } resp , err := d . sendPacket ( dlp ) if err != nil { return err } d . id = id if split := strings . Split ( resp . header ( ) , " " ) ; len ( split ) > 1 { for _ , f := range strings . Split ( split [ 1 ] , " " ) { switch { case f == " " : d . writable = true case strings . HasPrefix ( f , " " ) : size , err := strconv . ParseInt ( strings . Split ( f , " " ) [ 1 ] , 10 , 32 ) if err != nil { return fmt . Errorf ( " " , err ) } d . size = int ( size ) } } } return nil }
SetId sens an ID message to the remote connection and decodes the connection capabilities.
SetId sens an ID message to the remote connection and decodes the connection capabilities .
// Like: ID DataLink 2014.269 :: DLPROTO:1.0 PACKETSIZE:512 WRITE