Golang next step

Entry

This text has been translated by a translator https://translate.yandex.ru/?clid=2270456&win=320

If you meet errors it’s not me)) – this is a translator.

Golang developers are said to share their ideas. Let me dream what I would like to see in the language. all this is easily located and lies on the surface.

I know about Plugins (https://golang.org/pkg/plugin/#pkg-overview) but this is not a youth.

I want to have something like DLL in golang language. But DLL technology is for C++, besides it is inconvenient, not fashionable, as old as digested mammoth food

Golang need some new cool technology DLM!!! DLM – Dynamic Link Module.

Step 1

Dir: c:\mygoproject\client5\

File: Discount_customer.GODLM

func calculate_discount() int {

// the name of the function never changes

// what the complex algorithm

//

return 6 // algorithm changes frequently

}

Compile and get: Discount_customer.DLM – binary code.

File: start.go

package main

import ("fmt"

"dlm"

)

func main() {

MyModule := dlm.LoadDLM_file("Discount_customer.DLM")

discount := MyModule.calculate_discount()

fmt.Println("discount =", discount)

}

Compile and get start.exe

It’s simple. It’s like a DLL.

Step 2

func main() {
// …
address_module_in_database = "discount_calculation"
MyArrayByte := ReadFromDataBase(address_module_in_database)
MyModule := dlm.LoadDLM(MyArrayByte)
// …
}

So, we can connect to our main program not only a file which is a module, but also an array of bytes which is a module. The byte array itself can be anywhere, even in a database, even in a file, even in the body of the main program.

Step 3

I have a text file on disk: Discount_customer.GODLM

Or did I read the program text from the database

compile during the execution of our main program, then connect the compiled code to the main program

func main() {
// …
MyText := ReadTextFile("Discount_customer.GODLM")

MyArrayByte := dlm.Compile(MyText)

MyModule := dlm.LoadDLM(MyArrayByte)
// …
}

That’s what scaling is))

No need to stop the main server or recompile to fix anything

It’s cooler than LUA

This is faster than LUA, because our code will be compiled into byte code, not interpreted.

Python nervously smokes on the sidelines

Step 4

Now the language golang is in go.exe

next we divide the go.exe on: go.exe and on the go.dlm

the compiler is now located in go.dlm

Now I can take the go.dlm into my program to connect the go.dlm in my program and compile on the fly.

There is something called DLL hell. From what I understand DLM it’s the same thing. Maybe a better idea and natural in go is to create a custom package like this and use it throught the program. Or plugin.

Just my opinion ! :smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.