Home > other >  Goland file programming o bosses grant instruction
Goland file programming o bosses grant instruction

Time:12-23

Goland file more programming, prompt can not find the main module,
This kind of situation need to how to realize the file programming?

Three files in the code below:

The main. Go:


Package the main

//define interfaces
The type system interface {
//communication interface
CSocketProtocol ()
//encryption interface
CEncDesProtocol ()
}

//polymorphism
Func framework (I Intel) {
I.C SocketProtocol ()
I.C EncDesProtocol ()
}
Func main () {
Cs1: CSckImp1={" the encrypted data vendors 1 ", "the communication data vendors 1"}
The framework (& amp; Cs1)
Cs2: CSckImp2={" vendors to encrypt data of 2 ", "vendor communication data of 2", 55}
The framework (& amp; Cs2)

}


Manufacturers go:

Package the main

The import "FMT"

//vendor 1
Type CSckImp1 struct {
The data string
The socket string
}

Func (cs1 * CSckImp1) CSocketProtocol () {
FMT. Printf (" manufacturer 1 communication interface of the data is: % s \ n ", cs1. The socket)
}
Func (cs1 * CSckImp1) CEncDesProtocol () {
FMT. Printf (" encryption interface data for vendor 1: % s \ n ", cs1. Data)
}


Manufacturers (2) go:

Package the main

The import "FMT"

//vendor 2 class
Type CSckImp2 struct {
The data string
The socket string
The value int
}

Func (cs2 * CSckImp2) CSocketProtocol () {
FMT. Printf (" vendor communication interface of the data for 2: % s \ n ", cs2. Socket)
}
Func (cs2 * CSckImp2) CEncDesProtocol () {
FMT. Printf (" manufacturer 2 encryption interface for data: % s values for: % d \ n ", cs2. Data, cs2. Value)
}



Print the results: go: always find a main module; Go see 'help modules'

This kind of situation? Such as online

  • Related