Necessitates Proper Modularity

    @darabonba/go-generator

    1.1.2 • Public • Published

    English | 简体中文

    Darabonba Code Generator for Go

    NPM version build status codecov dependency status npm download

    Installation

    Darabonba Code Generator was designed to work in Node.js. The preferred way to install the Generator is to use the NPM package manager. Simply type the following into a terminal window:

    npm install @darabonba/go-generator

    Usage

    'use strict';
    
    const path = require('path');
    const fs = require('fs');
    
    const parser = require('@darabonba/parser');
    const Generator = require('@darabonba/go-generator');
    
    const sourceDir = "<Darabonda package directory>";
    const outputDir = "<Generate output directory>";
    
    // generate AST data by Parser
    let packageMetaFilePath = path.join(sourceDir, 'Darafile');
    let packageMeta = JSON.parse(fs.readFileSync(packageMetaFilePath, 'utf8'));
    let mainFile = path.join(sourceDir, packageMeta.main);
    let ast = parser.parse(fs.readFileSync(mainFile, 'utf8'), mainFile);
    
    // initialize generator
    let generatorConfig = {
      ...packageMeta,
      pkgDir: sourceDir,
      outputDir
    };
    
    let generator = new Generator(generatorConfig);
    
    // generate go code by generator
    generator.visit(ast);
    
    // The execution result will be output in the 'outputDir'

    Issues

    Opening an Issue, Issues not conforming to the guidelines may be closed immediately.

    Changelog

    Detailed changes for each release are documented in the release notes.

    License

    Apache-2.0 Copyright (c) 2009-present, Alibaba Cloud All rights reserved.

    Keywords

    none

    Install

    npm i @darabonba/go-generator

    DownloadsWeekly Downloads

    29

    Version

    1.1.2

    License

    Apache-2.0

    Unpacked Size

    216 kB

    Total Files

    100

    Last publish

    Collaborators

    • aliyunsdkteam
    • yndu13
    • jacksontian
    • pagecao