How to develop filter plug-in of ansible with golang

problem description

how to develop filter plug-ins for ansible with golang? The
module can be developed in go, and the filter plug-in doesn"t know if it works.

the platform version of the problem and what methods you have tried

python always has problems with single and double quotes, so it is intended to use golang.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
python version

def single_double(a_list):
    new_list = [ "%s" % an_element for an_element in a_list]
    -sharpreturn ""%s"" % new_list
    return new_list

class FilterModule(object):
    def filters(self):
        return {"single_double": single_double}

what result do you expect? What is the error message actually seen?

filter plug-ins for developing ansible using golang can provide some sample code

May.27,2021

after trying, it can be done using python.
what the previous practice filter returns is that the list, of python cannot be used directly as an array. You need to convert it to a string and return it to OK.

reason: insufficient understanding of python data structure

the implementation is as follows:

def to_join_http_port(nodes, hostvars, ansible_default_netname, port):
    """
    INPUT:
        nodes: groups.group_name
        hostsvars: ansible Built-in vars
        ansible_default_netname: ethernet name
        port: program server port
    RETURN:
        string like '"http://10.32.254.7:8081","http://10.32.254.8:8081","http://10.32.254.11:8081"'
    """
    ips = []
    for node in nodes:
        ips.append(hostvars[node][ansible_default_netname]["ipv4"]["address"])
    return ",".join([ '"http://%s:%s"' % (ip, port) for ip in ips ])


class FilterModule(object):
    def filters(self):
        return {
            'http_port_join': to_join_http_port
        }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb99b5-4fc3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb99b5-4fc3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?