Using node.js, we might have this:

const z = new Z();
exports.z = z

and then in another file we can import

import {z} from '../z'

with Golang, I am trying to do something similar:

package log

import Logger "github.com/foo/bar/logger"

// create an instance
var log = Logger.create()

// export the methods
var Info = log.Info
var Warn = log.Warn
var Error = log.Error

and then we import it like 

import "github.com/a/b/log"

func init(){
   log.Info("something")
   log.Warn("something")
}

/// ===========

basically what I am asking is if there is a way to create an instance and 
access it's methods - so that in my code I don't have to do:

log.log.Info()

but instead I can do:

log.Info()

hope the question makes sense.






-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2f80f567-91c1-46a5-9c7e-9f0f766c50cfn%40googlegroups.com.

Reply via email to