Load package dynamically

前端 未结 5 1743
-上瘾入骨i
-上瘾入骨i 2020-12-15 03:03

Is it possible to load a specific package during runtime? I want to have a kind of plugins where each one has the same functions than the others but with different behaviou

5条回答
  •  隐瞒了意图╮
    2020-12-15 03:41

    I think what you are looking for is the special function init

    if you add a

    func init() {
    
    }
    

    inside a package it will run it the first time the package is imported. This happens only in the same binary. As other have already said go does not support dynamically loaded libraries.

提交回复
热议问题